Merge lp:~percona-dev/percona-server/innodb-lru-auto-dump-restore into lp:percona-server/release-5.1.50-12
- innodb-lru-auto-dump-restore
- Merge into release-5.1.50-12
Status: | Merged |
---|---|
Merged at revision: | 124 |
Proposed branch: | lp:~percona-dev/percona-server/innodb-lru-auto-dump-restore |
Merge into: | lp:percona-server/release-5.1.50-12 |
Diff against target: |
376 lines (+264/-36) 1 file modified
innodb_lru_dump_restore.patch (+264/-36) |
To merge this branch: | bzr merge lp:~percona-dev/percona-server/innodb-lru-auto-dump-restore |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Yasufumi Kinoshita (community) | Approve | ||
Fred Linhoss (community) | documentation | Approve | |
Percona developers | Pending | ||
Review via email: mp+36642@code.launchpad.net |
Commit message
Description of the change
The implementation of automatic LRU dump / restore.
New variable added:
innodb_
* Time in seconds between automatic buffer pool dumps. 0 (the default) disables automatic dumps.
Yasufumi Kinoshita (yasufumi-kinoshita) wrote : | # |
Yasufumi Kinoshita (yasufumi-kinoshita) wrote : | # |
The thread should not be created the parameter is disabled
Vadim Tkachenko (vadim-tk) wrote : | # |
It was fixed, please review again
> os_thread_create() seems to conflict with purge_threads.
>
> n[] and thread_ids[] in srv0start.c should be extend, if you add new threads.
>
> (not needed header changes)
Vadim Tkachenko (vadim-tk) wrote : | # |
I decided to have thread created anyway, as parameter can be changed runtime.
> The thread should not be created the parameter is disabled
Yasufumi Kinoshita (yasufumi-kinoshita) wrote : | # |
Please don't break headers of diff and make keep clean to be reviewed easily, if you can.
The following changes are needed?
299 @@ -401,9 +493,9 @@
300
301 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
302 /******
303 -diff -ruN a/storage/
304 ---- a/storage/
305 -+++ b/storage/
306 +diff -r 4f856ddb44ca storage/
307 +--- a/storage/
308 ++++ b/storage/
309 @@ -31,6 +31,37 @@
310 #include "buf0types.h"
311
And,
218 @@ -239,10 +300,17 @@
219 ulint
220 buf_read_page_low(
221 /*==============*/
222 +<<<<<<< TREE
223 diff -ruN a/storage/
224 --- a/storage/
225 +++ b/storage/
226 @@ -4869,6 +4869,78 @@
227 +=======
228 +diff -r 4f856ddb44ca storage/
229 +--- a/storage/
230 ++++ b/storage/
231 +@@ -4869,6 +4869,78 @@
232 +>>>>>>> MERGE-SOURCE
233 return(DB_SUCCESS);
234 }
235
Vadim Tkachenko (vadim-tk) wrote : | # |
Yasufumi,
Header is unchanged is it ?
I am not sure where these diffs come from..
My patch is clean..
On Tue, Sep 28, 2010 at 5:54 PM, Yasufumi Kinoshita
<email address hidden> wrote:
> Please don't break headers of diff and make keep clean to be reviewed easily, if you can.
> The following changes are needed?
>
> 299 @@ -401,9 +493,9 @@
> 300
> 301 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
> 302 /******
> 303 -diff -ruN a/storage/
> 304 ---- a/storage/
> 305 -+++ b/storage/
> 306 +diff -r 4f856ddb44ca storage/
> 307 +--- a/storage/
> 308 ++++ b/storage/
> 309 @@ -31,6 +31,37 @@
> 310 #include "buf0types.h"
> 311
>
> And,
>
> 218 @@ -239,10 +300,17 @@
> 219 ulint
> 220 buf_read_page_low(
> 221 /*==============*/
> 222 +<<<<<<< TREE
> 223 diff -ruN a/storage/
> 224 --- a/storage/
> 225 +++ b/storage/
> 226 @@ -4869,6 +4869,78 @@
> 227 +=======
> 228 +diff -r 4f856ddb44ca storage/
> 229 +--- a/storage/
> 230 ++++ b/storage/
> 231 +@@ -4869,6 +4869,78 @@
> 232 +>>>>>>> MERGE-SOURCE
> 233 return(DB_SUCCESS);
> 234 }
> 235
> --
> https:/
> Your team Percona developers is requested to review the proposed merge of lp:~percona-dev/percona-server/innodb-lru-auto-dump-restore into lp:percona-server.
>
--
Vadim Tkachenko, CTO, Percona Inc.
Phone +1-888-401-3403, Skype: vadimtk153
Schedule meeting: http://
Yasufumi Kinoshita (yasufumi-kinoshita) wrote : | # |
If don't need to be changed, don't change for clearness of the diff.
And the later case seems not to be solved the conflict.
Yasufumi Kinoshita (yasufumi-kinoshita) wrote : | # |
I will adjust the branch tomorrow.
Please re-review then.
Fred Linhoss (fred-linhoss) wrote : | # |
Added system variable innodb_
Yasufumi Kinoshita (yasufumi-kinoshita) : | # |
Preview Diff
1 | === modified file 'innodb_lru_dump_restore.patch' | |||
2 | --- innodb_lru_dump_restore.patch 2010-09-24 07:24:56 +0000 | |||
3 | +++ innodb_lru_dump_restore.patch 2010-10-01 01:22:49 +0000 | |||
4 | @@ -8,7 +8,7 @@ | |||
5 | 8 | diff -ruN a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0lru.c | 8 | diff -ruN a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0lru.c |
6 | 9 | --- a/storage/innodb_plugin/buf/buf0lru.c 2010-08-27 16:13:11.070058073 +0900 | 9 | --- a/storage/innodb_plugin/buf/buf0lru.c 2010-08-27 16:13:11.070058073 +0900 |
7 | 10 | +++ b/storage/innodb_plugin/buf/buf0lru.c 2010-08-27 16:34:33.860400549 +0900 | 10 | +++ b/storage/innodb_plugin/buf/buf0lru.c 2010-08-27 16:34:33.860400549 +0900 |
9 | 11 | @@ -2122,6 +2122,218 @@ | 11 | @@ -2122,6 +2122,278 @@ |
10 | 12 | memset(&buf_LRU_stat_cur, 0, sizeof buf_LRU_stat_cur); | 12 | memset(&buf_LRU_stat_cur, 0, sizeof buf_LRU_stat_cur); |
11 | 13 | } | 13 | } |
12 | 14 | 14 | ||
13 | @@ -118,6 +118,26 @@ | |||
14 | 118 | + | 118 | + |
15 | 119 | + return(ret); | 119 | + return(ret); |
16 | 120 | +} | 120 | +} |
17 | 121 | + | ||
18 | 122 | +typedef struct { | ||
19 | 123 | + ib_uint32_t space_id; | ||
20 | 124 | + ib_uint32_t page_no; | ||
21 | 125 | +} dump_record_t; | ||
22 | 126 | + | ||
23 | 127 | +static int dump_record_cmp(const void *a, const void *b) | ||
24 | 128 | +{ | ||
25 | 129 | + const dump_record_t *rec1 = (dump_record_t *) a; | ||
26 | 130 | + const dump_record_t *rec2 = (dump_record_t *) b; | ||
27 | 131 | + | ||
28 | 132 | + if (rec1->space_id < rec2->space_id) | ||
29 | 133 | + return -1; | ||
30 | 134 | + if (rec1->space_id > rec2->space_id) | ||
31 | 135 | + return 1; | ||
32 | 136 | + if (rec1->page_no < rec2->page_no) | ||
33 | 137 | + return -1; | ||
34 | 138 | + return rec1->page_no > rec2->page_no; | ||
35 | 139 | +} | ||
36 | 140 | + | ||
37 | 121 | +/********************************************************************//** | 141 | +/********************************************************************//** |
38 | 122 | +Read the pages based on the specific file.*/ | 142 | +Read the pages based on the specific file.*/ |
39 | 123 | +UNIV_INTERN | 143 | +UNIV_INTERN |
40 | @@ -135,25 +155,34 @@ | |||
41 | 135 | + ulint req = 0; | 155 | + ulint req = 0; |
42 | 136 | + ibool terminated = FALSE; | 156 | + ibool terminated = FALSE; |
43 | 137 | + ibool ret = FALSE; | 157 | + ibool ret = FALSE; |
52 | 138 | + | 158 | + dump_record_t* records; |
53 | 139 | + buffer_base = ut_malloc(2 * UNIV_PAGE_SIZE); | 159 | + ulint size; |
54 | 140 | + buffer = ut_align(buffer_base, UNIV_PAGE_SIZE); | 160 | + ulint size_high; |
55 | 141 | + if (!buffer) { | 161 | + ulint length; |
48 | 142 | + fprintf(stderr, | ||
49 | 143 | + " InnoDB: cannot allocate buffer.\n"); | ||
50 | 144 | + goto end; | ||
51 | 145 | + } | ||
56 | 146 | + | 162 | + |
57 | 147 | + dump_file = os_file_create_simple_no_error_handling( | 163 | + dump_file = os_file_create_simple_no_error_handling( |
58 | 148 | + LRU_DUMP_FILE, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success); | 164 | + LRU_DUMP_FILE, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success); |
60 | 149 | + if (!success) { | 165 | + if (!success || !os_file_get_size(dump_file, &size, &size_high)) { |
61 | 150 | + os_file_get_last_error(TRUE); | 166 | + os_file_get_last_error(TRUE); |
62 | 151 | + fprintf(stderr, | 167 | + fprintf(stderr, |
63 | 152 | + " InnoDB: cannot open %s\n", LRU_DUMP_FILE); | 168 | + " InnoDB: cannot open %s\n", LRU_DUMP_FILE); |
64 | 153 | + goto end; | 169 | + goto end; |
65 | 154 | + } | 170 | + } |
66 | 171 | + if (size == 0 || size_high > 0 || size % 8) { | ||
67 | 172 | + fprintf(stderr, " InnoDB: broken LRU dump file\n"); | ||
68 | 173 | + goto end; | ||
69 | 174 | + } | ||
70 | 175 | + buffer_base = ut_malloc(2 * UNIV_PAGE_SIZE); | ||
71 | 176 | + buffer = ut_align(buffer_base, UNIV_PAGE_SIZE); | ||
72 | 177 | + records = ut_malloc(size); | ||
73 | 178 | + if (!buffer || !records) { | ||
74 | 179 | + fprintf(stderr, | ||
75 | 180 | + " InnoDB: cannot allocate buffer.\n"); | ||
76 | 181 | + goto end; | ||
77 | 182 | + } | ||
78 | 155 | + | 183 | + |
79 | 156 | + buffers = 0; | 184 | + buffers = 0; |
80 | 185 | + length = 0; | ||
81 | 157 | + while (!terminated) { | 186 | + while (!terminated) { |
82 | 158 | + success = os_file_read(dump_file, buffer, | 187 | + success = os_file_read(dump_file, buffer, |
83 | 159 | + (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL, | 188 | + (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL, |
84 | @@ -162,15 +191,14 @@ | |||
85 | 162 | + if (!success) { | 191 | + if (!success) { |
86 | 163 | + fprintf(stderr, | 192 | + fprintf(stderr, |
87 | 164 | + " InnoDB: cannot read page %lu of %s," | 193 | + " InnoDB: cannot read page %lu of %s," |
89 | 165 | + " or meet unexpected terminal.", | 194 | + " or meet unexpected terminal.\n", |
90 | 166 | + buffers, LRU_DUMP_FILE); | 195 | + buffers, LRU_DUMP_FILE); |
91 | 167 | + goto end; | 196 | + goto end; |
92 | 168 | + } | 197 | + } |
93 | 169 | + | 198 | + |
94 | 170 | + for (offset = 0; offset < UNIV_PAGE_SIZE/4; offset += 2) { | 199 | + for (offset = 0; offset < UNIV_PAGE_SIZE/4; offset += 2) { |
98 | 171 | + ulint space_id, zip_size, page_no; | 200 | + ulint space_id; |
99 | 172 | + ulint err; | 201 | + ulint page_no; |
97 | 173 | + ib_int64_t tablespace_version; | ||
100 | 174 | + | 202 | + |
101 | 175 | + space_id = mach_read_from_4(buffer + offset * 4); | 203 | + space_id = mach_read_from_4(buffer + offset * 4); |
102 | 176 | + page_no = mach_read_from_4(buffer + (offset + 1) * 4); | 204 | + page_no = mach_read_from_4(buffer + (offset + 1) * 4); |
103 | @@ -180,33 +208,63 @@ | |||
104 | 180 | + break; | 208 | + break; |
105 | 181 | + } | 209 | + } |
106 | 182 | + | 210 | + |
128 | 183 | + if (offset % 16 == 15) { | 211 | + records[length].space_id = space_id; |
129 | 184 | + os_aio_simulated_wake_handler_threads(); | 212 | + records[length].page_no = page_no; |
130 | 185 | + buf_flush_free_margin(FALSE); | 213 | + length++; |
131 | 186 | + } | 214 | + if (length * 8 >= size) { |
132 | 187 | + | 215 | + fprintf(stderr, |
133 | 188 | + zip_size = fil_space_get_zip_size(space_id); | 216 | + " InnoDB: could not find the " |
134 | 189 | + if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) { | 217 | + "end-of-file marker after reading " |
135 | 190 | + continue; | 218 | + "the expected %lu bytes from the " |
136 | 191 | + } | 219 | + "LRU dump file.\n" |
137 | 192 | + | 220 | + " InnoDB: this could be caused by a " |
138 | 193 | + if (fil_area_is_exist(space_id, zip_size, page_no, 0, | 221 | + "broken or incomplete file.\n" |
139 | 194 | + zip_size ? zip_size : UNIV_PAGE_SIZE)) { | 222 | + " InnoDB: trying to process what has " |
140 | 195 | + | 223 | + "been read so far.\n", |
141 | 196 | + tablespace_version = fil_space_get_version(space_id); | 224 | + size); |
142 | 197 | + | 225 | + terminated= TRUE; |
143 | 198 | + req++; | 226 | + break; |
123 | 199 | + reads += buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE | ||
124 | 200 | + | OS_AIO_SIMULATED_WAKE_LATER, | ||
125 | 201 | + space_id, zip_size, TRUE, | ||
126 | 202 | + tablespace_version, page_no, NULL); | ||
127 | 203 | + buf_LRU_stat_inc_io(); | ||
144 | 204 | + } | 227 | + } |
145 | 205 | + } | 228 | + } |
146 | 206 | + | ||
147 | 207 | + buffers++; | 229 | + buffers++; |
148 | 208 | + } | 230 | + } |
149 | 209 | + | 231 | + |
150 | 232 | + qsort(records, length, sizeof(dump_record_t), dump_record_cmp); | ||
151 | 233 | + | ||
152 | 234 | + for (offset = 0; offset < length; offset++) { | ||
153 | 235 | + ulint space_id; | ||
154 | 236 | + ulint page_no; | ||
155 | 237 | + ulint zip_size; | ||
156 | 238 | + ulint err; | ||
157 | 239 | + ib_int64_t tablespace_version; | ||
158 | 240 | + | ||
159 | 241 | + space_id = records[offset].space_id; | ||
160 | 242 | + page_no = records[offset].page_no; | ||
161 | 243 | + | ||
162 | 244 | + if (offset % 16 == 15) { | ||
163 | 245 | + os_aio_simulated_wake_handler_threads(); | ||
164 | 246 | + buf_flush_free_margin(FALSE); | ||
165 | 247 | + } | ||
166 | 248 | + | ||
167 | 249 | + zip_size = fil_space_get_zip_size(space_id); | ||
168 | 250 | + if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) { | ||
169 | 251 | + continue; | ||
170 | 252 | + } | ||
171 | 253 | + | ||
172 | 254 | + if (fil_area_is_exist(space_id, zip_size, page_no, 0, | ||
173 | 255 | + zip_size ? zip_size : UNIV_PAGE_SIZE)) { | ||
174 | 256 | + | ||
175 | 257 | + tablespace_version = fil_space_get_version(space_id); | ||
176 | 258 | + | ||
177 | 259 | + req++; | ||
178 | 260 | + reads += buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE | ||
179 | 261 | + | OS_AIO_SIMULATED_WAKE_LATER, | ||
180 | 262 | + space_id, zip_size, TRUE, | ||
181 | 263 | + tablespace_version, page_no, NULL); | ||
182 | 264 | + buf_LRU_stat_inc_io(); | ||
183 | 265 | + } | ||
184 | 266 | + } | ||
185 | 267 | + | ||
186 | 210 | + os_aio_simulated_wake_handler_threads(); | 268 | + os_aio_simulated_wake_handler_threads(); |
187 | 211 | + buf_flush_free_margin(FALSE); | 269 | + buf_flush_free_margin(FALSE); |
188 | 212 | + | 270 | + |
189 | @@ -220,6 +278,8 @@ | |||
190 | 220 | + os_file_close(dump_file); | 278 | + os_file_close(dump_file); |
191 | 221 | + if (buffer_base) | 279 | + if (buffer_base) |
192 | 222 | + ut_free(buffer_base); | 280 | + ut_free(buffer_base); |
193 | 281 | + if (records) | ||
194 | 282 | + ut_free(records); | ||
195 | 223 | + | 283 | + |
196 | 224 | + return(ret); | 284 | + return(ret); |
197 | 225 | +} | 285 | +} |
198 | @@ -321,6 +381,30 @@ | |||
199 | 321 | #ifndef UNIV_HOTBACKUP | 381 | #ifndef UNIV_HOTBACKUP |
200 | 322 | /**********************************************************************//** | 382 | /**********************************************************************//** |
201 | 323 | Waits for an aio operation to complete. This function is used to write the | 383 | Waits for an aio operation to complete. This function is used to write the |
202 | 384 | diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc | ||
203 | 385 | --- a/storage/innodb_plugin/handler/ha_innodb.cc 2010-10-01 09:57:56.486228425 +0900 | ||
204 | 386 | +++ b/storage/innodb_plugin/handler/ha_innodb.cc 2010-10-01 10:00:13.292228546 +0900 | ||
205 | 387 | @@ -11431,6 +11431,12 @@ | ||
206 | 388 | "Limit the allocated memory for dictionary cache. (0: unlimited)", | ||
207 | 389 | NULL, NULL, 0, 0, LONG_MAX, 0); | ||
208 | 390 | |||
209 | 391 | +static MYSQL_SYSVAR_UINT(auto_lru_dump, srv_auto_lru_dump, | ||
210 | 392 | + PLUGIN_VAR_RQCMDARG, | ||
211 | 393 | + "Time in seconds between automatic buffer pool dumps. " | ||
212 | 394 | + "0 (the default) disables automatic dumps.", | ||
213 | 395 | + NULL, NULL, 0, 0, UINT_MAX32, 0); | ||
214 | 396 | + | ||
215 | 397 | static struct st_mysql_sys_var* innobase_system_variables[]= { | ||
216 | 398 | MYSQL_SYSVAR(additional_mem_pool_size), | ||
217 | 399 | MYSQL_SYSVAR(autoextend_increment), | ||
218 | 400 | @@ -11510,6 +11516,7 @@ | ||
219 | 401 | MYSQL_SYSVAR(change_buffering), | ||
220 | 402 | MYSQL_SYSVAR(read_ahead_threshold), | ||
221 | 403 | MYSQL_SYSVAR(io_capacity), | ||
222 | 404 | + MYSQL_SYSVAR(auto_lru_dump), | ||
223 | 405 | MYSQL_SYSVAR(use_purge_thread), | ||
224 | 406 | NULL | ||
225 | 407 | }; | ||
226 | 324 | diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc | 408 | diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc |
227 | 325 | --- a/storage/innodb_plugin/handler/i_s.cc 2010-08-27 16:29:12.540979608 +0900 | 409 | --- a/storage/innodb_plugin/handler/i_s.cc 2010-08-27 16:29:12.540979608 +0900 |
228 | 326 | +++ b/storage/innodb_plugin/handler/i_s.cc 2010-08-27 16:34:33.873058189 +0900 | 410 | +++ b/storage/innodb_plugin/handler/i_s.cc 2010-08-27 16:34:33.873058189 +0900 |
229 | @@ -468,3 +552,147 @@ | |||
230 | 468 | /**********************************************************************//** | 552 | /**********************************************************************//** |
231 | 469 | Waits for an aio operation to complete. This function is used to write the | 553 | Waits for an aio operation to complete. This function is used to write the |
232 | 470 | handler for completed requests. The aio array of pending requests is divided | 554 | handler for completed requests. The aio array of pending requests is divided |
233 | 555 | diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h | ||
234 | 556 | --- a/storage/innodb_plugin/include/srv0srv.h 2010-10-01 09:57:56.500228711 +0900 | ||
235 | 557 | +++ b/storage/innodb_plugin/include/srv0srv.h 2010-10-01 10:00:13.302223409 +0900 | ||
236 | 558 | @@ -334,6 +334,9 @@ | ||
237 | 559 | reading of a disk page */ | ||
238 | 560 | extern ulint srv_buf_pool_reads; | ||
239 | 561 | |||
240 | 562 | +/** Time in seconds between automatic buffer pool dumps */ | ||
241 | 563 | +extern uint srv_auto_lru_dump; | ||
242 | 564 | + | ||
243 | 565 | /** Status variables to be passed to MySQL */ | ||
244 | 566 | typedef struct export_var_struct export_struc; | ||
245 | 567 | |||
246 | 568 | @@ -602,6 +605,16 @@ | ||
247 | 569 | /*=====================*/ | ||
248 | 570 | void* arg); /*!< in: a dummy parameter required by | ||
249 | 571 | os_thread_create */ | ||
250 | 572 | +/*********************************************************************//** | ||
251 | 573 | +A thread which restores the buffer pool from a dump file on startup and does | ||
252 | 574 | +periodic buffer pool dumps. | ||
253 | 575 | +@return a dummy parameter */ | ||
254 | 576 | +UNIV_INTERN | ||
255 | 577 | +os_thread_ret_t | ||
256 | 578 | +srv_LRU_dump_restore_thread( | ||
257 | 579 | +/*====================*/ | ||
258 | 580 | + void* arg); /*!< in: a dummy parameter required by | ||
259 | 581 | + os_thread_create */ | ||
260 | 582 | /******************************************************************//** | ||
261 | 583 | Outputs to a file the output of the InnoDB Monitor. | ||
262 | 584 | @return FALSE if not all information printed | ||
263 | 585 | diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c | ||
264 | 586 | --- a/storage/innodb_plugin/srv/srv0srv.c 2010-10-01 09:57:56.516255101 +0900 | ||
265 | 587 | +++ b/storage/innodb_plugin/srv/srv0srv.c 2010-10-01 10:00:13.304230973 +0900 | ||
266 | 588 | @@ -298,6 +298,9 @@ | ||
267 | 589 | reading of a disk page */ | ||
268 | 590 | UNIV_INTERN ulint srv_buf_pool_reads = 0; | ||
269 | 591 | |||
270 | 592 | +/** Time in seconds between automatic buffer pool dumps */ | ||
271 | 593 | +UNIV_INTERN uint srv_auto_lru_dump = 0; | ||
272 | 594 | + | ||
273 | 595 | /* structure to pass status variables to MySQL */ | ||
274 | 596 | UNIV_INTERN export_struc export_vars; | ||
275 | 597 | |||
276 | 598 | @@ -2537,6 +2540,56 @@ | ||
277 | 599 | /* We count the number of threads in os_thread_exit(). A created | ||
278 | 600 | thread should always use that to exit and not use return() to exit. */ | ||
279 | 601 | |||
280 | 602 | + os_thread_exit(NULL); | ||
281 | 603 | + | ||
282 | 604 | + OS_THREAD_DUMMY_RETURN; | ||
283 | 605 | +} | ||
284 | 606 | + | ||
285 | 607 | +/*********************************************************************//** | ||
286 | 608 | +A thread which restores the buffer pool from a dump file on startup and does | ||
287 | 609 | +periodic buffer pool dumps. | ||
288 | 610 | +@return a dummy parameter */ | ||
289 | 611 | +UNIV_INTERN | ||
290 | 612 | +os_thread_ret_t | ||
291 | 613 | +srv_LRU_dump_restore_thread( | ||
292 | 614 | +/*====================*/ | ||
293 | 615 | + void* arg __attribute__((unused))) | ||
294 | 616 | + /*!< in: a dummy parameter required by | ||
295 | 617 | + os_thread_create */ | ||
296 | 618 | +{ | ||
297 | 619 | + uint auto_lru_dump; | ||
298 | 620 | + time_t last_dump_time; | ||
299 | 621 | + time_t time_elapsed; | ||
300 | 622 | + | ||
301 | 623 | +#ifdef UNIV_DEBUG_THREAD_CREATION | ||
302 | 624 | + fprintf(stderr, "LRU dump/restore thread starts, id %lu\n", | ||
303 | 625 | + os_thread_pf(os_thread_get_curr_id())); | ||
304 | 626 | +#endif | ||
305 | 627 | + | ||
306 | 628 | + if (srv_auto_lru_dump) | ||
307 | 629 | + buf_LRU_file_restore(); | ||
308 | 630 | + | ||
309 | 631 | + last_dump_time = time(NULL); | ||
310 | 632 | + | ||
311 | 633 | +loop: | ||
312 | 634 | + os_thread_sleep(5000000); | ||
313 | 635 | + | ||
314 | 636 | + if (srv_shutdown_state >= SRV_SHUTDOWN_CLEANUP) { | ||
315 | 637 | + goto exit_func; | ||
316 | 638 | + } | ||
317 | 639 | + | ||
318 | 640 | + time_elapsed = time(NULL) - last_dump_time; | ||
319 | 641 | + auto_lru_dump = srv_auto_lru_dump; | ||
320 | 642 | + if (auto_lru_dump > 0 && (time_t) auto_lru_dump < time_elapsed) { | ||
321 | 643 | + last_dump_time = time(NULL); | ||
322 | 644 | + buf_LRU_file_dump(); | ||
323 | 645 | + } | ||
324 | 646 | + | ||
325 | 647 | + goto loop; | ||
326 | 648 | +exit_func: | ||
327 | 649 | + /* We count the number of threads in os_thread_exit(). A created | ||
328 | 650 | + thread should always use that to exit and not use return() to exit. */ | ||
329 | 651 | + | ||
330 | 652 | os_thread_exit(NULL); | ||
331 | 653 | |||
332 | 654 | OS_THREAD_DUMMY_RETURN; | ||
333 | 655 | diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c | ||
334 | 656 | --- a/storage/innodb_plugin/srv/srv0start.c 2010-10-01 09:57:56.420229366 +0900 | ||
335 | 657 | +++ b/storage/innodb_plugin/srv/srv0start.c 2010-10-01 10:00:13.309260428 +0900 | ||
336 | 658 | @@ -126,9 +126,9 @@ | ||
337 | 659 | static ulint ios; | ||
338 | 660 | |||
339 | 661 | /** io_handler_thread parameters for thread identification */ | ||
340 | 662 | -static ulint n[SRV_MAX_N_IO_THREADS + 6 + 64]; | ||
341 | 663 | +static ulint n[SRV_MAX_N_IO_THREADS + 7 + 64]; | ||
342 | 664 | /** io_handler_thread identifiers */ | ||
343 | 665 | -static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6 + 64]; | ||
344 | 666 | +static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 7 + 64]; | ||
345 | 667 | |||
346 | 668 | /** We use this mutex to test the return value of pthread_mutex_trylock | ||
347 | 669 | on successful locking. HP-UX does NOT return 0, though Linux et al do. */ | ||
348 | 670 | @@ -1683,6 +1683,10 @@ | ||
349 | 671 | os_thread_create(&srv_monitor_thread, NULL, | ||
350 | 672 | thread_ids + 4 + SRV_MAX_N_IO_THREADS); | ||
351 | 673 | |||
352 | 674 | + /* Create the thread which automaticaly dumps/restore buffer pool */ | ||
353 | 675 | + os_thread_create(&srv_LRU_dump_restore_thread, NULL, | ||
354 | 676 | + thread_ids + 5 + SRV_MAX_N_IO_THREADS); | ||
355 | 677 | + | ||
356 | 678 | srv_is_being_started = FALSE; | ||
357 | 679 | |||
358 | 680 | if (trx_doublewrite == NULL) { | ||
359 | 681 | @@ -1707,13 +1711,13 @@ | ||
360 | 682 | ulint i; | ||
361 | 683 | |||
362 | 684 | os_thread_create(&srv_purge_thread, NULL, thread_ids | ||
363 | 685 | - + (5 + SRV_MAX_N_IO_THREADS)); | ||
364 | 686 | + + (6 + SRV_MAX_N_IO_THREADS)); | ||
365 | 687 | |||
366 | 688 | for (i = 0; i < srv_use_purge_thread - 1; i++) { | ||
367 | 689 | - n[6 + i + SRV_MAX_N_IO_THREADS] = i; /* using as index for arrays in purge_sys */ | ||
368 | 690 | + n[7 + i + SRV_MAX_N_IO_THREADS] = i; /* using as index for arrays in purge_sys */ | ||
369 | 691 | os_thread_create(&srv_purge_worker_thread, | ||
370 | 692 | - n + (6 + i + SRV_MAX_N_IO_THREADS), | ||
371 | 693 | - thread_ids + (6 + i + SRV_MAX_N_IO_THREADS)); | ||
372 | 694 | + n + (7 + i + SRV_MAX_N_IO_THREADS), | ||
373 | 695 | + thread_ids + (7 + i + SRV_MAX_N_IO_THREADS)); | ||
374 | 696 | } | ||
375 | 697 | } | ||
376 | 698 | #ifdef UNIV_DEBUG |
os_thread_create() seems to conflict with purge_threads.
n[] and thread_ids[] in srv0start.c should be extend, if you add new threads.
(not needed header changes)