102.1.1
by kinoyasu
add header and rule, as the first step of the reordering patch for separate release |
1 |
# name : innodb_purge_thread.patch |
2 |
# introduced : 11 or before |
|
3 |
# maintainer : Yasufumi |
|
4 |
# |
|
5 |
#!!! notice !!! |
|
6 |
# Any small change to this file in the main branch |
|
7 |
# should be done or reviewed by the maintainer! |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
8 |
diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
|
9 |
--- a/storage/innodb_plugin/handler/ha_innodb.cc 2010-08-27 16:23:31.022060427 +0900
|
|
10 |
+++ b/storage/innodb_plugin/handler/ha_innodb.cc 2010-08-27 16:25:49.004020662 +0900
|
|
215.1.1
by Yasufumi Kinoshita
fix bug733317 |
11 |
@@ -11064,6 +11064,11 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
12 |
"Output statistics of recovery process after it.", |
13 |
NULL, NULL, FALSE); |
|
14 |
||
15 |
+static MYSQL_SYSVAR_ULONG(use_purge_thread, srv_use_purge_thread,
|
|
16 |
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
|
|
17 |
+ "Number of purge devoted threads. #### over 1 is EXPERIMENTAL ####",
|
|
219.3.1
by Laurynas Biveinis
Properly limit the maximum number of purge threads |
18 |
+ NULL, NULL, 0, 0, UNIV_MAX_PARALLELISM, 0);
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
19 |
+
|
20 |
static MYSQL_SYSVAR_BOOL(overwrite_relay_log_info, innobase_overwrite_relay_log_info, |
|
21 |
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, |
|
22 |
"During InnoDB crash recovery on slave overwrite relay-log.info " |
|
215.1.1
by Yasufumi Kinoshita
fix bug733317 |
23 |
@@ -11575,6 +11580,7 @@
|
149
by kinoyasu
ported Yasufumi patches for 5.1.53 |
24 |
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ |
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
25 |
MYSQL_SYSVAR(read_ahead_threshold), |
26 |
MYSQL_SYSVAR(io_capacity), |
|
27 |
+ MYSQL_SYSVAR(use_purge_thread),
|
|
28 |
NULL |
|
29 |
}; |
|
30 |
||
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
31 |
diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
|
32 |
--- a/storage/innodb_plugin/handler/innodb_patch_info.h 2010-08-27 16:23:31.027058629 +0900
|
|
33 |
+++ b/storage/innodb_plugin/handler/innodb_patch_info.h 2010-08-27 16:25:49.004020662 +0900
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
34 |
@@ -37,5 +37,6 @@
|
35 |
{"innodb_split_buf_pool_mutex","More fix of buffer_pool mutex","Spliting buf_pool_mutex and optimizing based on innodb_opt_lru_count","http://www.percona.com/docs/wiki/percona-xtradb"}, |
|
36 |
{"innodb_stats","Additional features about InnoDB statistics/optimizer","","http://www.percona.com/docs/wiki/percona-xtradb"}, |
|
37 |
{"innodb_recovery_patches","Bugfixes and adjustments about recovery process","","http://www.percona.com/docs/wiki/percona-xtradb"}, |
|
38 |
+{"innodb_purge_thread","Enable to use purge devoted thread","","http://www.percona.com/docs/wiki/percona-xtradb"},
|
|
39 |
{NULL, NULL, NULL, NULL} |
|
40 |
}; |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
41 |
diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
|
42 |
--- a/storage/innodb_plugin/include/srv0srv.h 2010-08-27 16:23:31.030059162 +0900
|
|
43 |
+++ b/storage/innodb_plugin/include/srv0srv.h 2010-08-27 16:25:49.005987844 +0900
|
|
9
by kinoyasu
port for 5.1.47-1.0.8 |
44 |
@@ -116,6 +116,8 @@
|
45 |
||
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
46 |
extern ibool srv_recovery_stats; |
47 |
||
48 |
+extern ulint srv_use_purge_thread;
|
|
49 |
+
|
|
50 |
extern ibool srv_auto_extend_last_data_file; |
|
51 |
extern ulint srv_last_file_size_max; |
|
52 |
extern char** srv_log_group_home_dirs; |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
53 |
@@ -421,6 +423,8 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
54 |
SRV_RECOVERY, /**< threads finishing a recovery */ |
55 |
SRV_INSERT, /**< thread flushing the insert buffer to disk */ |
|
56 |
#endif |
|
57 |
+ SRV_PURGE, /* thread purging undo records */
|
|
58 |
+ SRV_PURGE_WORKER, /* thread purging undo records */
|
|
59 |
SRV_MASTER /**< the master thread, (whose type number must |
|
60 |
be biggest) */ |
|
61 |
}; |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
62 |
@@ -494,6 +498,21 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
63 |
/*==============*/ |
64 |
void* arg); /*!< in: a dummy parameter required by |
|
65 |
os_thread_create */ |
|
66 |
+/*************************************************************************
|
|
67 |
+The undo purge thread. */
|
|
68 |
+UNIV_INTERN
|
|
69 |
+os_thread_ret_t
|
|
70 |
+srv_purge_thread(
|
|
71 |
+/*=============*/
|
|
72 |
+ void* arg); /* in: a dummy parameter required by
|
|
73 |
+ os_thread_create */
|
|
74 |
+/*************************************************************************
|
|
75 |
+The undo purge thread. */
|
|
76 |
+UNIV_INTERN
|
|
77 |
+os_thread_ret_t
|
|
78 |
+srv_purge_worker_thread(
|
|
79 |
+/*====================*/
|
|
80 |
+ void* arg);
|
|
81 |
/*******************************************************************//** |
|
82 |
Tells the Innobase server that there has been activity in the database |
|
83 |
and wakes up the master thread if it is suspended (not sleeping). Used |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
84 |
diff -ruN a/storage/innodb_plugin/include/trx0purge.h b/storage/innodb_plugin/include/trx0purge.h
|
85 |
--- a/storage/innodb_plugin/include/trx0purge.h 2010-08-04 02:24:19.000000000 +0900
|
|
86 |
+++ b/storage/innodb_plugin/include/trx0purge.h 2010-08-27 16:25:49.006988119 +0900
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
87 |
@@ -114,6 +114,25 @@
|
88 |
ulint |
|
89 |
trx_purge(void); |
|
90 |
/*===========*/ |
|
91 |
+/**********************************************************************
|
|
92 |
+This function runs a purge worker batch */
|
|
93 |
+UNIV_INTERN
|
|
94 |
+void
|
|
95 |
+trx_purge_worker(
|
|
96 |
+/*=============*/
|
|
97 |
+ ulint worker_id);
|
|
98 |
+/**********************************************************************
|
|
99 |
+This function waits the event for worker batch */
|
|
100 |
+UNIV_INTERN
|
|
101 |
+void
|
|
102 |
+trx_purge_worker_wait(void);
|
|
103 |
+/*========================*/
|
|
104 |
+/**********************************************************************
|
|
105 |
+This function wakes the waiting worker batch */
|
|
106 |
+UNIV_INTERN
|
|
107 |
+void
|
|
108 |
+trx_purge_worker_wake(void);
|
|
109 |
+/*========================*/
|
|
110 |
/******************************************************************//** |
|
111 |
Prints information of the purge system to stderr. */ |
|
112 |
UNIV_INTERN |
|
113 |
@@ -131,6 +150,11 @@
|
|
114 |
of the trx system and it never ends */ |
|
115 |
que_t* query; /*!< The query graph which will do the |
|
116 |
parallelized purge operation */ |
|
117 |
+ ulint n_worker;
|
|
118 |
+ os_event_t worker_event;
|
|
119 |
+ sess_t** sess_arr;
|
|
120 |
+ trx_t** trx_arr;
|
|
121 |
+ que_t** query_arr;
|
|
122 |
rw_lock_t latch; /*!< The latch protecting the purge view. |
|
123 |
A purge operation must acquire an |
|
124 |
x-latch here for the instant at which |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
125 |
diff -ruN a/storage/innodb_plugin/log/log0log.c b/storage/innodb_plugin/log/log0log.c
|
126 |
--- a/storage/innodb_plugin/log/log0log.c 2010-08-27 15:54:18.086987682 +0900
|
|
127 |
+++ b/storage/innodb_plugin/log/log0log.c 2010-08-27 16:25:49.010020843 +0900
|
|
77
by kinoyasu
port and adjust the part of the patches to 5.1.49: But query_cache_with_comments.patch, response-time-distribution.patch, mysql_remove_eol_carret.patch, log_connection_error.patch, status_wait_query_cache_mutex.patch and sql_no_fcache.patch were not ported yet. Please port them. |
128 |
@@ -3150,6 +3150,16 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
129 |
goto loop; |
130 |
} |
|
131 |
||
132 |
+ /* Check that the purge threads ended */
|
|
133 |
+ if (srv_use_purge_thread
|
|
134 |
+ && (srv_n_threads_active[SRV_PURGE] != 0
|
|
135 |
+ || srv_n_threads_active[SRV_PURGE_WORKER] != 0)) {
|
|
136 |
+
|
|
137 |
+ mutex_exit(&kernel_mutex);
|
|
138 |
+
|
|
139 |
+ goto loop;
|
|
140 |
+ }
|
|
141 |
+
|
|
142 |
mutex_exit(&kernel_mutex); |
|
143 |
||
144 |
mutex_enter(&(log_sys->mutex)); |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
145 |
diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
|
146 |
--- a/storage/innodb_plugin/srv/srv0srv.c 2010-08-27 16:23:31.042058997 +0900
|
|
147 |
+++ b/storage/innodb_plugin/srv/srv0srv.c 2010-08-27 16:25:49.014058600 +0900
|
|
9
by kinoyasu
port for 5.1.47-1.0.8 |
148 |
@@ -146,6 +146,8 @@
|
149 |
||
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
150 |
UNIV_INTERN ibool srv_recovery_stats = FALSE; |
151 |
||
152 |
+UNIV_INTERN ulint srv_use_purge_thread = 0;
|
|
153 |
+
|
|
154 |
/* if TRUE, then we auto-extend the last data file */ |
|
155 |
UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE; |
|
156 |
/* if != 0, this tells the max size auto-extending may increase the |
|
225
by kinoyasu
port Yasufumi patches to 5.1.57 |
157 |
@@ -2639,10 +2641,10 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
158 |
srv_main_thread_process_no = os_proc_get_number(); |
159 |
srv_main_thread_id = os_thread_pf(os_thread_get_curr_id()); |
|
160 |
||
161 |
- srv_table_reserve_slot(SRV_MASTER);
|
|
162 |
||
163 |
mutex_enter(&kernel_mutex); |
|
164 |
||
165 |
+ srv_table_reserve_slot(SRV_MASTER);
|
|
166 |
srv_n_threads_active[SRV_MASTER]++; |
|
167 |
||
168 |
mutex_exit(&kernel_mutex); |
|
225
by kinoyasu
port Yasufumi patches to 5.1.57 |
169 |
@@ -3100,6 +3102,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
170 |
/* Flush logs if needed */ |
171 |
srv_sync_log_buffer_in_background(); |
|
172 |
||
173 |
+ if (!srv_use_purge_thread) {
|
|
174 |
/* We run a full purge every 10 seconds, even if the server |
|
175 |
were active */ |
|
176 |
do { |
|
225
by kinoyasu
port Yasufumi patches to 5.1.57 |
177 |
@@ -3116,6 +3119,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
178 |
srv_sync_log_buffer_in_background(); |
179 |
||
180 |
} while (n_pages_purged); |
|
181 |
+ }
|
|
182 |
||
183 |
srv_main_thread_op_info = "flushing buffer pool pages"; |
|
184 |
||
225
by kinoyasu
port Yasufumi patches to 5.1.57 |
185 |
@@ -3184,6 +3188,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
186 |
os_thread_sleep(100000); |
187 |
} |
|
188 |
||
189 |
+ if (!srv_use_purge_thread) {
|
|
190 |
srv_main_thread_op_info = "purging"; |
|
191 |
||
192 |
/* Run a full purge */ |
|
225
by kinoyasu
port Yasufumi patches to 5.1.57 |
193 |
@@ -3200,6 +3205,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
194 |
srv_sync_log_buffer_in_background(); |
195 |
||
196 |
} while (n_pages_purged); |
|
197 |
+ }
|
|
198 |
||
199 |
srv_main_thread_op_info = "reserving kernel mutex"; |
|
200 |
||
225
by kinoyasu
port Yasufumi patches to 5.1.57 |
201 |
@@ -3352,3 +3358,143 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
202 |
|
203 |
OS_THREAD_DUMMY_RETURN; /* Not reached, avoid compiler warning */ |
|
204 |
} |
|
205 |
+
|
|
206 |
+/*************************************************************************
|
|
207 |
+A thread which is devoted to purge, for take over the master thread's
|
|
208 |
+purging */
|
|
209 |
+UNIV_INTERN
|
|
210 |
+os_thread_ret_t
|
|
211 |
+srv_purge_thread(
|
|
212 |
+/*=============*/
|
|
213 |
+ void* arg __attribute__((unused)))
|
|
214 |
+ /* in: a dummy parameter required by os_thread_create */
|
|
215 |
+{
|
|
216 |
+ ulint n_pages_purged;
|
|
217 |
+ ulint n_pages_purged_sum = 1; /* dummy */
|
|
218 |
+ ulint history_len;
|
|
219 |
+ ulint sleep_ms= 10000; /* initial: 10 sec. */
|
|
220 |
+ ibool can_be_last = FALSE;
|
|
221 |
+
|
|
222 |
+#ifdef UNIV_DEBUG_THREAD_CREATION
|
|
223 |
+ fprintf(stderr, "Purge thread starts, id %lu\n",
|
|
224 |
+ os_thread_pf(os_thread_get_curr_id()));
|
|
225 |
+#endif
|
|
226 |
+
|
|
227 |
+ mutex_enter(&kernel_mutex);
|
|
228 |
+ srv_table_reserve_slot(SRV_PURGE);
|
|
229 |
+ srv_n_threads_active[SRV_PURGE]++;
|
|
230 |
+ mutex_exit(&kernel_mutex);
|
|
231 |
+
|
|
232 |
+loop:
|
|
233 |
+ if (srv_shutdown_state > 0) {
|
|
234 |
+ if (srv_fast_shutdown) {
|
|
235 |
+ /* someone other should wait the end of the workers */
|
|
236 |
+ goto exit_func;
|
|
237 |
+ }
|
|
238 |
+
|
|
239 |
+ mutex_enter(&kernel_mutex);
|
|
240 |
+ if (srv_n_threads_active[SRV_PURGE_WORKER]) {
|
|
241 |
+ can_be_last = FALSE;
|
|
242 |
+ } else {
|
|
243 |
+ can_be_last = TRUE;
|
|
244 |
+ }
|
|
245 |
+ mutex_exit(&kernel_mutex);
|
|
246 |
+
|
|
247 |
+ sleep_ms = 10;
|
|
248 |
+ }
|
|
249 |
+
|
|
250 |
+ os_thread_sleep( sleep_ms * 1000 );
|
|
251 |
+
|
|
252 |
+ history_len = trx_sys->rseg_history_len;
|
|
253 |
+ if (history_len > 1000)
|
|
254 |
+ sleep_ms /= 10;
|
|
255 |
+ if (sleep_ms < 10)
|
|
256 |
+ sleep_ms = 10;
|
|
257 |
+
|
|
258 |
+ n_pages_purged_sum = 0;
|
|
259 |
+
|
|
260 |
+ do {
|
|
261 |
+ if (srv_fast_shutdown && srv_shutdown_state > 0) {
|
|
262 |
+ goto exit_func;
|
|
263 |
+ }
|
|
264 |
+ n_pages_purged = trx_purge();
|
|
265 |
+ n_pages_purged_sum += n_pages_purged;
|
|
266 |
+ } while (n_pages_purged);
|
|
267 |
+
|
|
268 |
+ if (srv_shutdown_state > 0 && can_be_last) {
|
|
269 |
+ /* the last trx_purge() is executed without workers */
|
|
270 |
+ goto exit_func;
|
|
271 |
+ }
|
|
272 |
+
|
|
273 |
+ if (n_pages_purged_sum) {
|
|
274 |
+ srv_active_wake_master_thread();
|
|
275 |
+ }
|
|
276 |
+
|
|
277 |
+ if (n_pages_purged_sum == 0)
|
|
278 |
+ sleep_ms *= 10;
|
|
279 |
+ if (sleep_ms > 10000)
|
|
280 |
+ sleep_ms = 10000;
|
|
281 |
+
|
|
282 |
+ goto loop;
|
|
283 |
+
|
|
284 |
+exit_func:
|
|
285 |
+ trx_purge_worker_wake(); /* It may not make sense. for safety only */
|
|
286 |
+
|
|
287 |
+ /* wake master thread to flush the pages */
|
|
288 |
+ srv_wake_master_thread();
|
|
289 |
+
|
|
290 |
+ mutex_enter(&kernel_mutex);
|
|
291 |
+ srv_n_threads_active[SRV_PURGE]--;
|
|
292 |
+ mutex_exit(&kernel_mutex);
|
|
293 |
+ os_thread_exit(NULL);
|
|
294 |
+
|
|
295 |
+ OS_THREAD_DUMMY_RETURN;
|
|
296 |
+}
|
|
297 |
+
|
|
298 |
+/*************************************************************************
|
|
299 |
+A thread which is devoted to purge, for take over the master thread's
|
|
300 |
+purging */
|
|
301 |
+UNIV_INTERN
|
|
302 |
+os_thread_ret_t
|
|
303 |
+srv_purge_worker_thread(
|
|
304 |
+/*====================*/
|
|
305 |
+ void* arg)
|
|
306 |
+{
|
|
307 |
+ ulint worker_id; /* index for array */
|
|
308 |
+
|
|
309 |
+ worker_id = *((ulint*)arg);
|
|
310 |
+
|
|
311 |
+#ifdef UNIV_DEBUG_THREAD_CREATION
|
|
312 |
+ fprintf(stderr, "Purge worker thread starts, id %lu\n",
|
|
313 |
+ os_thread_pf(os_thread_get_curr_id()));
|
|
314 |
+#endif
|
|
315 |
+ mutex_enter(&kernel_mutex);
|
|
316 |
+ srv_table_reserve_slot(SRV_PURGE_WORKER);
|
|
317 |
+ srv_n_threads_active[SRV_PURGE_WORKER]++;
|
|
318 |
+ mutex_exit(&kernel_mutex);
|
|
319 |
+
|
|
320 |
+loop:
|
|
321 |
+ /* purge worker threads only works when srv_shutdown_state==0 */
|
|
322 |
+ /* for safety and exactness. */
|
|
323 |
+ if (srv_shutdown_state > 0) {
|
|
324 |
+ goto exit_func;
|
|
325 |
+ }
|
|
326 |
+
|
|
327 |
+ trx_purge_worker_wait();
|
|
328 |
+
|
|
329 |
+ if (srv_shutdown_state > 0) {
|
|
330 |
+ goto exit_func;
|
|
331 |
+ }
|
|
332 |
+
|
|
333 |
+ trx_purge_worker(worker_id);
|
|
334 |
+
|
|
335 |
+ goto loop;
|
|
336 |
+
|
|
337 |
+exit_func:
|
|
338 |
+ mutex_enter(&kernel_mutex);
|
|
339 |
+ srv_n_threads_active[SRV_PURGE_WORKER]--;
|
|
340 |
+ mutex_exit(&kernel_mutex);
|
|
341 |
+ os_thread_exit(NULL);
|
|
342 |
+
|
|
343 |
+ OS_THREAD_DUMMY_RETURN;
|
|
344 |
+}
|
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
345 |
diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c
|
346 |
--- a/storage/innodb_plugin/srv/srv0start.c 2010-08-27 15:59:21.760987922 +0900
|
|
347 |
+++ b/storage/innodb_plugin/srv/srv0start.c 2010-08-27 16:25:49.017058492 +0900
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
348 |
@@ -126,9 +126,9 @@
|
349 |
static ulint ios; |
|
350 |
||
351 |
/** io_handler_thread parameters for thread identification */ |
|
352 |
-static ulint n[SRV_MAX_N_IO_THREADS + 6];
|
|
219.3.1
by Laurynas Biveinis
Properly limit the maximum number of purge threads |
353 |
+static ulint n[SRV_MAX_N_IO_THREADS + 6 + UNIV_MAX_PARALLELISM];
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
354 |
/** io_handler_thread identifiers */ |
355 |
-static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6];
|
|
219.3.1
by Laurynas Biveinis
Properly limit the maximum number of purge threads |
356 |
+static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6 + UNIV_MAX_PARALLELISM];
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
357 |
|
358 |
/** We use this mutex to test the return value of pthread_mutex_trylock |
|
359 |
on successful locking. HP-UX does NOT return 0, though Linux et al do. */ |
|
225
by kinoyasu
port Yasufumi patches to 5.1.57 |
360 |
@@ -1725,6 +1725,20 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
361 |
|
362 |
os_thread_create(&srv_master_thread, NULL, thread_ids |
|
363 |
+ (1 + SRV_MAX_N_IO_THREADS)); |
|
364 |
+
|
|
365 |
+ if (srv_use_purge_thread) {
|
|
366 |
+ ulint i;
|
|
367 |
+
|
|
368 |
+ os_thread_create(&srv_purge_thread, NULL, thread_ids
|
|
369 |
+ + (5 + SRV_MAX_N_IO_THREADS));
|
|
370 |
+
|
|
371 |
+ for (i = 0; i < srv_use_purge_thread - 1; i++) {
|
|
372 |
+ n[6 + i + SRV_MAX_N_IO_THREADS] = i; /* using as index for arrays in purge_sys */
|
|
373 |
+ os_thread_create(&srv_purge_worker_thread,
|
|
374 |
+ n + (6 + i + SRV_MAX_N_IO_THREADS),
|
|
375 |
+ thread_ids + (6 + i + SRV_MAX_N_IO_THREADS));
|
|
376 |
+ }
|
|
377 |
+ }
|
|
378 |
#ifdef UNIV_DEBUG |
|
379 |
/* buf_debug_prints = TRUE; */ |
|
380 |
#endif /* UNIV_DEBUG */ |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
381 |
diff -ruN a/storage/innodb_plugin/trx/trx0purge.c b/storage/innodb_plugin/trx/trx0purge.c
|
382 |
--- a/storage/innodb_plugin/trx/trx0purge.c 2010-08-04 02:24:20.000000000 +0900
|
|
383 |
+++ b/storage/innodb_plugin/trx/trx0purge.c 2010-08-27 16:25:49.020058576 +0900
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
384 |
@@ -184,8 +184,9 @@
|
385 |
@return own: the query graph */ |
|
386 |
static |
|
387 |
que_t* |
|
388 |
-trx_purge_graph_build(void)
|
|
389 |
+trx_purge_graph_build(
|
|
390 |
/*=======================*/ |
|
391 |
+ trx_t* trx)
|
|
392 |
{ |
|
393 |
mem_heap_t* heap; |
|
394 |
que_fork_t* fork; |
|
395 |
@@ -194,7 +195,7 @@
|
|
396 |
||
397 |
heap = mem_heap_create(512); |
|
398 |
fork = que_fork_create(NULL, NULL, QUE_FORK_PURGE, heap); |
|
399 |
- fork->trx = purge_sys->trx;
|
|
400 |
+ fork->trx = trx;
|
|
401 |
||
402 |
thr = que_thr_create(fork, heap); |
|
403 |
||
404 |
@@ -243,10 +244,35 @@
|
|
405 |
||
406 |
ut_a(trx_start_low(purge_sys->trx, ULINT_UNDEFINED)); |
|
407 |
||
408 |
- purge_sys->query = trx_purge_graph_build();
|
|
409 |
+ purge_sys->query = trx_purge_graph_build(purge_sys->trx);
|
|
410 |
||
411 |
purge_sys->view = read_view_oldest_copy_or_open_new(ut_dulint_zero, |
|
412 |
purge_sys->heap); |
|
413 |
+
|
|
414 |
+ purge_sys->n_worker = 0;
|
|
415 |
+ if (srv_use_purge_thread > 1) {
|
|
416 |
+ /* Use worker threads */
|
|
417 |
+ ulint i;
|
|
418 |
+
|
|
419 |
+ purge_sys->n_worker = srv_use_purge_thread - 1;
|
|
420 |
+
|
|
421 |
+ purge_sys->sess_arr = mem_alloc(sizeof(sess_t*) * purge_sys->n_worker);
|
|
422 |
+ purge_sys->trx_arr = mem_alloc(sizeof(trx_t*) * purge_sys->n_worker);
|
|
423 |
+ purge_sys->query_arr = mem_alloc(sizeof(que_t*) * purge_sys->n_worker);
|
|
424 |
+
|
|
425 |
+ purge_sys->worker_event = os_event_create(NULL);
|
|
426 |
+ os_event_reset(purge_sys->worker_event);
|
|
427 |
+
|
|
428 |
+ for (i = 0; i < purge_sys->n_worker; i++) {
|
|
429 |
+ purge_sys->sess_arr[i] = sess_open();
|
|
430 |
+
|
|
431 |
+ purge_sys->trx_arr[i] = purge_sys->sess_arr[i]->trx;
|
|
432 |
+ purge_sys->trx_arr[i]->is_purge = 1;
|
|
433 |
+ ut_a(trx_start_low(purge_sys->trx_arr[i], ULINT_UNDEFINED));
|
|
434 |
+
|
|
435 |
+ purge_sys->query_arr[i] = trx_purge_graph_build(purge_sys->trx_arr[i]);
|
|
436 |
+ }
|
|
437 |
+ }
|
|
438 |
} |
|
439 |
||
440 |
/************************************************************************ |
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
441 |
@@ -1144,7 +1170,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
442 |
|
443 |
/* Handle at most 20 undo log pages in one purge batch */ |
|
444 |
||
445 |
- purge_sys->handle_limit = purge_sys->n_pages_handled + 20;
|
|
446 |
+ purge_sys->handle_limit = purge_sys->n_pages_handled + 20 * (srv_use_purge_thread + 1);
|
|
447 |
||
448 |
old_pages_handled = purge_sys->n_pages_handled; |
|
449 |
||
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
450 |
@@ -1163,6 +1189,9 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
451 |
|
452 |
mutex_exit(&kernel_mutex); |
|
453 |
||
454 |
+ if (purge_sys->n_worker)
|
|
455 |
+ os_event_set(purge_sys->worker_event);
|
|
456 |
+
|
|
457 |
/* srv_que_task_enqueue(thr2); */ |
|
458 |
||
459 |
if (srv_print_thread_releases) { |
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
460 |
@@ -1172,6 +1201,9 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
461 |
|
462 |
que_run_threads(thr); |
|
463 |
||
464 |
+ if (purge_sys->n_worker)
|
|
465 |
+ os_event_reset(purge_sys->worker_event);
|
|
466 |
+
|
|
467 |
if (srv_print_thread_releases) { |
|
468 |
||
469 |
fprintf(stderr, |
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
470 |
@@ -1182,6 +1214,52 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
471 |
return(purge_sys->n_pages_handled - old_pages_handled); |
472 |
} |
|
473 |
||
474 |
+/**********************************************************************
|
|
475 |
+This function runs a purge worker batch */
|
|
476 |
+UNIV_INTERN
|
|
477 |
+void
|
|
478 |
+trx_purge_worker(
|
|
479 |
+/*=============*/
|
|
480 |
+ ulint worker_id)
|
|
481 |
+{
|
|
482 |
+ que_thr_t* thr;
|
|
483 |
+
|
|
484 |
+ mutex_enter(&kernel_mutex);
|
|
485 |
+
|
|
486 |
+ thr = que_fork_start_command(purge_sys->query_arr[worker_id]);
|
|
487 |
+
|
|
488 |
+ ut_ad(thr);
|
|
489 |
+
|
|
490 |
+ mutex_exit(&kernel_mutex);
|
|
491 |
+
|
|
492 |
+ que_run_threads(thr);
|
|
493 |
+
|
|
494 |
+ if (purge_sys->state == TRX_STOP_PURGE) { /* optimistic */
|
|
495 |
+ os_event_reset(purge_sys->worker_event);
|
|
496 |
+ }
|
|
497 |
+}
|
|
498 |
+
|
|
499 |
+/**********************************************************************
|
|
500 |
+This function waits the event for worker batch */
|
|
501 |
+UNIV_INTERN
|
|
502 |
+void
|
|
503 |
+trx_purge_worker_wait(void)
|
|
504 |
+/*=======================*/
|
|
505 |
+{
|
|
506 |
+ os_event_wait(purge_sys->worker_event);
|
|
507 |
+}
|
|
508 |
+
|
|
509 |
+/**********************************************************************
|
|
510 |
+This function wakes the waiting worker batch */
|
|
511 |
+UNIV_INTERN
|
|
512 |
+void
|
|
513 |
+trx_purge_worker_wake(void)
|
|
514 |
+/*=======================*/
|
|
515 |
+{
|
|
516 |
+ if (purge_sys->n_worker)
|
|
517 |
+ os_event_set(purge_sys->worker_event);
|
|
518 |
+}
|
|
519 |
+
|
|
520 |
/******************************************************************//** |
|
521 |
Prints information of the purge system to stderr. */ |
|
522 |
UNIV_INTERN |