summaryrefslogtreecommitdiff
blob: 1c8f4299cb2988b47e1d70440b2506571de0aa33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
diff -ruN a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
--- a/innobase/include/srv0srv.h	2009-05-06 15:35:46.000000000 +0900
+++ b/innobase/include/srv0srv.h	2009-05-06 13:37:45.000000000 +0900
@@ -147,6 +147,8 @@
 extern uint	srv_read_ahead;
 extern ulint	srv_adaptive_checkpoint;
 
+extern ulint	srv_extra_rsegments;
+
 extern ulint	srv_dict_size_limit;
 
 extern volatile ibool srv_io_pattern;
diff -ruN a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
--- a/innobase/include/trx0sys.h	2009-05-06 15:35:46.000000000 +0900
+++ b/innobase/include/trx0sys.h	2009-05-06 14:52:00.000000000 +0900
@@ -105,6 +105,13 @@
 void
 trx_sys_create(void);
 /*================*/
+/*********************************************************************
+Create extra rollback segments when create_new_db */
+
+void
+trx_sys_create_extra_rseg(
+/*======================*/
+	ulint	num);	/* in: number of extra user rollback segments */
 /********************************************************************
 Looks for a free slot for a rollback segment in the trx system file copy. */
 
diff -ruN a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
--- a/innobase/srv/srv0srv.c	2009-05-06 15:35:46.000000000 +0900
+++ b/innobase/srv/srv0srv.c	2009-05-06 13:38:23.000000000 +0900
@@ -347,6 +347,8 @@
 uint	srv_read_ahead = 3; /* 1: random  2: linear  3: Both */
 ulint	srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
 
+ulint	srv_extra_rsegments = 0; /* extra rseg for users */
+
 ulint	srv_dict_size_limit = 0;
 
 volatile ibool srv_io_pattern = FALSE;
diff -ruN a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
--- a/innobase/srv/srv0start.c	2009-05-06 15:35:46.000000000 +0900
+++ b/innobase/srv/srv0start.c	2009-05-06 14:54:43.000000000 +0900
@@ -1418,6 +1418,8 @@
 		dict_create();
                 srv_startup_is_before_trx_rollback_phase = FALSE;
 
+		if (srv_extra_rsegments)
+			trx_sys_create_extra_rseg(srv_extra_rsegments);
 #ifdef UNIV_LOG_ARCHIVE
 	} else if (srv_archive_recovery) {
 		fprintf(stderr,
diff -ruN a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
--- a/innobase/trx/trx0sys.c	2009-05-06 15:35:46.000000000 +0900
+++ b/innobase/trx/trx0sys.c	2009-05-06 14:54:02.000000000 +0900
@@ -944,3 +944,28 @@
 
 	trx_sys_init_at_db_start();
 }
+
+/*********************************************************************
+Create extra rollback segments when create_new_db */
+
+void
+trx_sys_create_extra_rseg(
+/*======================*/
+	ulint	num)	/* in: number of extra user rollback segments */
+{
+	mtr_t	mtr;
+	ulint	slot_no;
+	ulint	i;
+
+	/* Craete extra rollback segments */
+	mtr_start(&mtr);
+	for (i = 1; i < num + 1; i++) {
+		if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
+			fprintf(stderr,
+"InnoDB: Warning: Failed to create extra rollback segments.\n");
+			break;
+		}
+		ut_a(slot_no == i);
+	}
+	mtr_commit(&mtr);
+}
diff -ruN a/patch_info/innodb_extra_rseg.info b/patch_info/innodb_extra_rseg.info
--- /dev/null	1970-01-01 09:00:00.000000000 +0900
+++ b/patch_info/innodb_extra_rseg.info	2009-05-06 14:49:48.000000000 +0900
@@ -0,0 +1,6 @@
+File=innodb_extra_rseg.patch
+Name=allow to create extra rollback segments
+Version=1.0
+Author=Percona <info@percona.com>
+License=GPL
+Comment
diff -ruN a/sql/ha_innodb.cc b/sql/ha_innodb.cc
--- a/sql/ha_innodb.cc	2009-05-06 15:35:46.000000000 +0900
+++ b/sql/ha_innodb.cc	2009-05-06 15:27:49.000000000 +0900
@@ -152,6 +152,7 @@
      innobase_open_files;
 
 long innobase_read_io_threads, innobase_write_io_threads;
+long innobase_extra_rsegments;
 longlong innobase_buffer_pool_size, innobase_log_file_size;
 
 /* The default values for the following char* start-up parameters
@@ -1507,6 +1508,8 @@
 	srv_n_read_io_threads = (ulint) innobase_read_io_threads;
 	srv_n_write_io_threads = (ulint) innobase_write_io_threads;
 
+	srv_extra_rsegments = (ulint) innobase_extra_rsegments;
+
 	srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout;
 	srv_force_recovery = (ulint) innobase_force_recovery;
 
diff -ruN a/sql/ha_innodb.h b/sql/ha_innodb.h
--- a/sql/ha_innodb.h	2009-05-06 15:35:46.000000000 +0900
+++ b/sql/ha_innodb.h	2009-05-06 13:51:35.000000000 +0900
@@ -205,6 +205,7 @@
 extern long innobase_buffer_pool_awe_mem_mb;
 extern long innobase_file_io_threads, innobase_lock_wait_timeout;
 extern long innobase_read_io_threads, innobase_write_io_threads;
+extern long innobase_extra_rsegments;
 extern long innobase_force_recovery;
 extern long innobase_open_files;
 extern char *innobase_data_home_dir, *innobase_data_file_path;
diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2009-05-06 15:35:46.000000000 +0900
+++ b/sql/mysqld.cc	2009-05-06 14:12:05.000000000 +0900
@@ -5096,6 +5096,7 @@
   OPT_INNODB_ADAPTIVE_CHECKPOINT,
   OPT_INNODB_READ_IO_THREADS,
   OPT_INNODB_WRITE_IO_THREADS,
+  OPT_INNODB_EXTRA_RSEGMENTS,
   OPT_INNODB_DICT_SIZE_LIMIT,
   OPT_INNODB_ADAPTIVE_HASH_INDEX,
   OPT_RPL_MIRROR_BINLOG,
@@ -5454,6 +5455,10 @@
    "Number of background write I/O threads in InnoDB.",
    (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
    0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
+  {"innodb_extra_rsegments", OPT_INNODB_EXTRA_RSEGMENTS,
+   "Number of extra user rollback segments when create new database.",
+   (gptr*) &innobase_extra_rsegments, (gptr*) &innobase_extra_rsegments,
+   0, GET_LONG, REQUIRED_ARG, 0, 0, 127, 0, 0, 0},
   {"innodb_dict_size_limit", OPT_INNODB_DICT_SIZE_LIMIT,
    "Limit the allocated memory for dictionary cache. (0: unlimited)",
    (gptr*) &srv_dict_size_limit, (gptr*) &srv_dict_size_limit, 0,
diff -ruN a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc	2009-05-06 15:35:46.000000000 +0900
+++ b/sql/set_var.cc	2009-05-06 14:13:24.000000000 +0900
@@ -1063,6 +1063,7 @@
   {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS},
   {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG},
   {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG},
+  {"innodb_extra_rsegments", (char*) &innobase_extra_rsegments, SHOW_LONG},
   {sys_innodb_dict_size_limit.name, (char*) &sys_innodb_dict_size_limit, SHOW_SYS},
   {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS},
   {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS},
diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
--- a/sql/sql_show.cc	2009-05-06 15:35:46.000000000 +0900
+++ b/sql/sql_show.cc	2009-05-06 15:29:47.000000000 +0900
@@ -39,6 +39,8 @@
 #include "srv0srv.h"
 #include "buf0buf.h"
 #include "dict0dict.h"
+#include "trx0rseg.h" /* for trx_rseg_struct */
+#include "trx0sys.h" /* for trx_sys */
 }
 /* We need to undef it in InnoDB */
 #undef byte
@@ -4160,6 +4162,45 @@
   DBUG_RETURN(returnable);
 }
 
+int
+innodb_rseg_fill(
+/*=================*/
+	THD*		thd,	/* in: thread */
+	TABLE_LIST*	tables,	/* in/out: tables to fill */
+	COND*		cond)	/* in: condition (ignored) */
+{
+	TABLE*	table	= (TABLE *) tables->table;
+	int	status	= 0;
+	trx_rseg_t*	rseg;
+
+	DBUG_ENTER("innodb_rseg_fill");
+
+	/* deny access to non-superusers */
+	if (check_global_access(thd, PROCESS_ACL)) {
+
+		DBUG_RETURN(0);
+	}
+
+	rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
+
+	while (rseg) {
+		table->field[0]->store(rseg->id);
+		table->field[1]->store(rseg->space);
+		table->field[2]->store(rseg->page_no);
+		table->field[3]->store(rseg->max_size);
+		table->field[4]->store(rseg->curr_size);
+
+		if (schema_table_store_record(thd, table)) {
+			status = 1;
+			break;
+		}
+
+		rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
+	}
+
+	DBUG_RETURN(status);
+}
+
 /*
   Find schema_tables elment by name
 
@@ -4978,6 +5019,16 @@
   {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
 };
+
+ST_FIELD_INFO innodb_rseg_fields_info[]=
+{
+  {"RSEG_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
+  {"SPACE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
+  {"PAGE_NO", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
+  {"MAX_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
+  {"CURR_SIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, ""},
+  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
+};
 #endif
 
 ST_FIELD_INFO variables_fields_info[]=
@@ -5157,6 +5208,8 @@
 #ifdef HAVE_INNOBASE_DB
   {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
     innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
+  {"INNODB_RSEG", innodb_rseg_fields_info, create_schema_table,
+    innodb_rseg_fill, 0, 0, -1, -1, 0},
 #endif
   {0, 0, 0, 0, 0, 0, 0, 0, 0}
 };