]> git.pld-linux.org Git - packages/mysql.git/blob - innodb_lru_dump_restore.patch
- up to 5.5.15
[packages/mysql.git] / innodb_lru_dump_restore.patch
1 # name       : innodb_lru_dump_restore.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!
8 --- a/storage/innobase/buf/buf0lru.c
9 +++ b/storage/innobase/buf/buf0lru.c
10 @@ -2167,6 +2167,284 @@
11         memset(&buf_LRU_stat_cur, 0, sizeof buf_LRU_stat_cur);
12  }
13  
14 +/********************************************************************//**
15 +Dump the LRU page list to the specific file. */
16 +#define LRU_DUMP_FILE "ib_lru_dump"
17 +
18 +UNIV_INTERN
19 +ibool
20 +buf_LRU_file_dump(void)
21 +/*===================*/
22 +{
23 +       os_file_t       dump_file = -1;
24 +       ibool           success;
25 +       byte*           buffer_base = NULL;
26 +       byte*           buffer = NULL;
27 +       buf_page_t*     bpage;
28 +       ulint           buffers;
29 +       ulint           offset;
30 +       ibool           ret = FALSE;
31 +       ulint           i;
32 +
33 +       for (i = 0; i < srv_n_data_files; i++) {
34 +               if (strstr(srv_data_file_names[i], LRU_DUMP_FILE) != NULL) {
35 +                       fprintf(stderr,
36 +                               " InnoDB: The name '%s' seems to be used for"
37 +                               " innodb_data_file_path. For safety, dumping of the LRU list"
38 +                               " is not being done.\n", LRU_DUMP_FILE);
39 +                       goto end;
40 +               }
41 +       }
42 +
43 +       buffer_base = ut_malloc(2 * UNIV_PAGE_SIZE);
44 +       buffer = ut_align(buffer_base, UNIV_PAGE_SIZE);
45 +       if (!buffer) {
46 +               fprintf(stderr,
47 +                       " InnoDB: cannot allocate buffer.\n");
48 +               goto end;
49 +       }
50 +
51 +       dump_file = os_file_create(innodb_file_temp_key, LRU_DUMP_FILE, OS_FILE_OVERWRITE,
52 +                               OS_FILE_NORMAL, OS_DATA_FILE, &success);
53 +       if (!success) {
54 +               os_file_get_last_error(TRUE);
55 +               fprintf(stderr,
56 +                       " InnoDB: cannot open %s\n", LRU_DUMP_FILE);
57 +               goto end;
58 +       }
59 +
60 +       buffers = offset = 0;
61 +
62 +       for (i = 0; i < srv_buf_pool_instances; i++) {
63 +               buf_pool_t*     buf_pool;
64 +
65 +               buf_pool = buf_pool_from_array(i);
66 +
67 +               mutex_enter(&buf_pool->LRU_list_mutex);
68 +               bpage = UT_LIST_GET_LAST(buf_pool->LRU);
69 +
70 +               while (bpage != NULL) {
71 +                       if (offset == 0) {
72 +                               memset(buffer, 0, UNIV_PAGE_SIZE);
73 +                       }
74 +
75 +                       mach_write_to_4(buffer + offset * 4, bpage->space);
76 +                       offset++;
77 +                       mach_write_to_4(buffer + offset * 4, bpage->offset);
78 +                       offset++;
79 +
80 +                       if (offset == UNIV_PAGE_SIZE/4) {
81 +                               success = os_file_write(LRU_DUMP_FILE, dump_file, buffer,
82 +                                               (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL,
83 +                                               (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)),
84 +                                               UNIV_PAGE_SIZE);
85 +                               if (!success) {
86 +                                       mutex_exit(&buf_pool->LRU_list_mutex);
87 +                                       fprintf(stderr,
88 +                                               " InnoDB: cannot write page %lu of %s\n",
89 +                                               buffers, LRU_DUMP_FILE);
90 +                                       goto end;
91 +                               }
92 +                               buffers++;
93 +                               offset = 0;
94 +                       }
95 +
96 +                       bpage = UT_LIST_GET_PREV(LRU, bpage);
97 +               }
98 +               mutex_exit(&buf_pool->LRU_list_mutex);
99 +       }
100 +
101 +       if (offset == 0) {
102 +               memset(buffer, 0, UNIV_PAGE_SIZE);
103 +       }
104 +
105 +       mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
106 +       offset++;
107 +       mach_write_to_4(buffer + offset * 4, 0xFFFFFFFFUL);
108 +       offset++;
109 +
110 +       success = os_file_write(LRU_DUMP_FILE, dump_file, buffer,
111 +                       (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL,
112 +                       (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)),
113 +                       UNIV_PAGE_SIZE);
114 +       if (!success) {
115 +               goto end;
116 +       }
117 +
118 +       ret = TRUE;
119 +end:
120 +       if (dump_file != -1)
121 +               os_file_close(dump_file);
122 +       if (buffer_base)
123 +               ut_free(buffer_base);
124 +
125 +       return(ret);
126 +}
127 +
128 +typedef struct {
129 +       ib_uint32_t space_id;
130 +       ib_uint32_t page_no;
131 +} dump_record_t;
132 +
133 +static int dump_record_cmp(const void *a, const void *b)
134 +{
135 +       const dump_record_t *rec1 = (dump_record_t *) a;
136 +       const dump_record_t *rec2 = (dump_record_t *) b;
137 +
138 +       if (rec1->space_id < rec2->space_id)
139 +               return -1;
140 +       if (rec1->space_id > rec2->space_id)
141 +               return 1;
142 +       if (rec1->page_no < rec2->page_no)
143 +               return -1;
144 +       return rec1->page_no > rec2->page_no;
145 +}
146 +
147 +/********************************************************************//**
148 +Read the pages based on the specific file.*/
149 +UNIV_INTERN
150 +ibool
151 +buf_LRU_file_restore(void)
152 +/*======================*/
153 +{
154 +       os_file_t       dump_file = -1;
155 +       ibool           success;
156 +       byte*           buffer_base = NULL;
157 +       byte*           buffer = NULL;
158 +       ulint           buffers;
159 +       ulint           offset;
160 +       ulint           reads = 0;
161 +       ulint           req = 0;
162 +       ibool           terminated = FALSE;
163 +       ibool           ret = FALSE;
164 +       dump_record_t*  records = NULL;
165 +       ulint           size;
166 +       ulint           size_high;
167 +       ulint           length;
168 +
169 +       dump_file = os_file_create_simple_no_error_handling(innodb_file_temp_key,
170 +               LRU_DUMP_FILE, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
171 +       if (!success || !os_file_get_size(dump_file, &size, &size_high)) {
172 +               os_file_get_last_error(TRUE);
173 +               fprintf(stderr,
174 +                       " InnoDB: cannot open %s\n", LRU_DUMP_FILE);
175 +               goto end;
176 +       }
177 +       if (size == 0 || size_high > 0 || size % 8) {
178 +               fprintf(stderr, " InnoDB: broken LRU dump file\n");
179 +               goto end;
180 +       }
181 +       buffer_base = ut_malloc(2 * UNIV_PAGE_SIZE);
182 +       buffer = ut_align(buffer_base, UNIV_PAGE_SIZE);
183 +       records = ut_malloc(size);
184 +       if (!buffer || !records) {
185 +               fprintf(stderr,
186 +                       " InnoDB: cannot allocate buffer.\n");
187 +               goto end;
188 +       }
189 +
190 +       buffers = 0;
191 +       length = 0;
192 +       while (!terminated) {
193 +               success = os_file_read(dump_file, buffer,
194 +                               (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL,
195 +                               (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)),
196 +                               UNIV_PAGE_SIZE);
197 +               if (!success) {
198 +                       fprintf(stderr,
199 +                               " InnoDB: either could not read page %lu of %s,"
200 +                               " or terminated unexpectedly.\n",
201 +                               buffers, LRU_DUMP_FILE);
202 +                       goto end;
203 +               }
204 +
205 +               for (offset = 0; offset < UNIV_PAGE_SIZE/4; offset += 2) {
206 +                       ulint   space_id;
207 +                       ulint   page_no;
208 +
209 +                       space_id = mach_read_from_4(buffer + offset * 4);
210 +                       page_no = mach_read_from_4(buffer + (offset + 1) * 4);
211 +                       if (space_id == 0xFFFFFFFFUL
212 +                           || page_no == 0xFFFFFFFFUL) {
213 +                               terminated = TRUE;
214 +                               break;
215 +                       }
216 +
217 +                       records[length].space_id = space_id;
218 +                       records[length].page_no = page_no;
219 +                       length++;
220 +                       if (length * 8 >= size) {
221 +                               fprintf(stderr,
222 +                                       " InnoDB: could not find the "
223 +                                       "end-of-file marker after reading "
224 +                                       "the expected %lu bytes from the "
225 +                                       "LRU dump file.\n"
226 +                                       " InnoDB: this could be caused by a "
227 +                                       "broken or incomplete file.\n"
228 +                                       " InnoDB: trying to process what has "
229 +                                       "been read so far.\n",
230 +                                       size);
231 +                               terminated= TRUE;
232 +                               break;
233 +                       }
234 +               }
235 +               buffers++;
236 +       }
237 +
238 +       qsort(records, length, sizeof(dump_record_t), dump_record_cmp);
239 +
240 +       for (offset = 0; offset < length; offset++) {
241 +               ulint           space_id;
242 +               ulint           page_no;
243 +               ulint           zip_size;
244 +               ulint           err;
245 +               ib_int64_t      tablespace_version;
246 +
247 +               space_id = records[offset].space_id;
248 +               page_no = records[offset].page_no;
249 +
250 +               if (offset % 16 == 15) {
251 +                       os_aio_simulated_wake_handler_threads();
252 +                       buf_flush_free_margins(FALSE);
253 +               }
254 +
255 +               zip_size = fil_space_get_zip_size(space_id);
256 +               if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
257 +                       continue;
258 +               }
259 +
260 +               if (fil_is_exist(space_id, page_no)) {
261 +
262 +                       tablespace_version = fil_space_get_version(space_id);
263 +
264 +                       req++;
265 +                       reads += buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
266 +                                                  | OS_AIO_SIMULATED_WAKE_LATER,
267 +                                                  space_id, zip_size, TRUE,
268 +                                                  tablespace_version, page_no, NULL);
269 +                       buf_LRU_stat_inc_io();
270 +               }
271 +       }
272 +
273 +       os_aio_simulated_wake_handler_threads();
274 +       buf_flush_free_margins(FALSE);
275 +
276 +       ut_print_timestamp(stderr);
277 +       fprintf(stderr,
278 +               " InnoDB: reading pages based on the dumped LRU list was done."
279 +               " (requested: %lu, read: %lu)\n", req, reads);
280 +       ret = TRUE;
281 +end:
282 +       if (dump_file != -1)
283 +               os_file_close(dump_file);
284 +       if (buffer_base)
285 +               ut_free(buffer_base);
286 +       if (records)
287 +               ut_free(records);
288 +
289 +       return(ret);
290 +}
291 +
292  #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
293  /**********************************************************************//**
294  Validates the LRU list for one buffer pool instance. */
295 --- a/storage/innobase/buf/buf0rea.c
296 +++ b/storage/innobase/buf/buf0rea.c
297 @@ -58,7 +58,7 @@
298  which case it is never read into the pool, or if the tablespace does
299  not exist or is being dropped 
300  @return 1 if read request is issued. 0 if it is not */
301 -static
302 +UNIV_INTERN
303  ulint
304  buf_read_page_low(
305  /*==============*/
306 --- a/storage/innobase/fil/fil0fil.c
307 +++ b/storage/innobase/fil/fil0fil.c
308 @@ -5290,6 +5290,70 @@
309         return(DB_SUCCESS);
310  }
311  
312 +/********************************************************************//**
313 +Confirm whether the parameters are valid or not */
314 +UNIV_INTERN
315 +ibool
316 +fil_is_exist(
317 +/*==============*/
318 +       ulint   space_id,       /*!< in: space id */
319 +       ulint   block_offset)   /*!< in: offset in number of blocks */
320 +{
321 +       fil_space_t*    space;
322 +       fil_node_t*     node;
323 +
324 +       /* Reserve the fil_system mutex and make sure that we can open at
325 +       least one file while holding it, if the file is not already open */
326 +
327 +       fil_mutex_enter_and_prepare_for_io(space_id);
328 +
329 +       space = fil_space_get_by_id(space_id);
330 +
331 +       if (!space) {
332 +               mutex_exit(&fil_system->mutex);
333 +               return(FALSE);
334 +       }
335 +
336 +       node = UT_LIST_GET_FIRST(space->chain);
337 +
338 +       for (;;) {
339 +               if (UNIV_UNLIKELY(node == NULL)) {
340 +                       mutex_exit(&fil_system->mutex);
341 +                       return(FALSE);
342 +               }
343 +
344 +               if (space->id != 0 && node->size == 0) {
345 +                       /* We do not know the size of a single-table tablespace
346 +                       before we open the file */
347 +
348 +                       break;
349 +               }
350 +
351 +               if (node->size > block_offset) {
352 +                       /* Found! */
353 +                       break;
354 +               } else {
355 +                       block_offset -= node->size;
356 +                       node = UT_LIST_GET_NEXT(chain, node);
357 +               }
358 +       }
359 +
360 +       /* Open file if closed */
361 +       fil_node_prepare_for_io(node, fil_system, space);
362 +       fil_node_complete_io(node, fil_system, OS_FILE_READ);
363 +
364 +       /* Check that at least the start offset is within the bounds of a
365 +       single-table tablespace */
366 +       if (UNIV_UNLIKELY(node->size <= block_offset)
367 +           && space->id != 0 && space->purpose == FIL_TABLESPACE) {
368 +               mutex_exit(&fil_system->mutex);
369 +               return(FALSE);
370 +       }
371 +
372 +       mutex_exit(&fil_system->mutex);
373 +       return(TRUE);
374 +}
375 +
376  #ifndef UNIV_HOTBACKUP
377  /**********************************************************************//**
378  Waits for an aio operation to complete. This function is used to write the
379 --- a/storage/innobase/handler/ha_innodb.cc
380 +++ b/storage/innobase/handler/ha_innodb.cc
381 @@ -11809,6 +11809,12 @@
382    "Limit the allocated memory for dictionary cache. (0: unlimited)",
383    NULL, NULL, 0, 0, LONG_MAX, 0);
384  
385 +static MYSQL_SYSVAR_UINT(buffer_pool_restore_at_startup, srv_auto_lru_dump,
386 +  PLUGIN_VAR_RQCMDARG,
387 +  "Time in seconds between automatic buffer pool dumps. "
388 +  "0 (the default) disables automatic dumps.",
389 +  NULL, NULL, 0, 0, UINT_MAX32, 0);
390 +
391  static struct st_mysql_sys_var* innobase_system_variables[]= {
392    MYSQL_SYSVAR(additional_mem_pool_size),
393    MYSQL_SYSVAR(autoextend_increment),
394 @@ -11891,6 +11897,7 @@
395  #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
396    MYSQL_SYSVAR(read_ahead_threshold),
397    MYSQL_SYSVAR(io_capacity),
398 +  MYSQL_SYSVAR(buffer_pool_restore_at_startup),
399    MYSQL_SYSVAR(purge_threads),
400    MYSQL_SYSVAR(purge_batch_size),
401    MYSQL_SYSVAR(rollback_segments),
402 --- a/storage/innobase/handler/i_s.cc
403 +++ b/storage/innobase/handler/i_s.cc
404 @@ -50,6 +50,7 @@
405  #include "trx0rseg.h" /* for trx_rseg_struct */
406  #include "trx0sys.h" /* for trx_sys */
407  #include "dict0dict.h" /* for dict_sys */
408 +#include "buf0lru.h" /* for XTRA_LRU_[DUMP/RESTORE] */
409  }
410  
411  #define OK(expr)               \
412 @@ -4270,6 +4271,36 @@
413                         "Hello!");
414                 goto end_func;
415         }
416 +       else if (!strncasecmp("XTRA_LRU_DUMP", ptr, 13)) {
417 +               ut_print_timestamp(stderr);
418 +               fprintf(stderr, " InnoDB: Administrative command 'XTRA_LRU_DUMP'"
419 +                               " was detected.\n");
420 +
421 +               if (buf_LRU_file_dump()) {
422 +                       field_store_string(i_s_table->field[0],
423 +                               "XTRA_LRU_DUMP was succeeded.");
424 +               } else {
425 +                       field_store_string(i_s_table->field[0],
426 +                               "XTRA_LRU_DUMP was failed.");
427 +               }
428 +
429 +               goto end_func;
430 +       }
431 +       else if (!strncasecmp("XTRA_LRU_RESTORE", ptr, 16)) {
432 +               ut_print_timestamp(stderr);
433 +               fprintf(stderr, " InnoDB: Administrative command 'XTRA_LRU_RESTORE'"
434 +                               " was detected.\n");
435 +
436 +               if (buf_LRU_file_restore()) {
437 +                       field_store_string(i_s_table->field[0],
438 +                               "XTRA_LRU_RESTORE was succeeded.");
439 +               } else {
440 +                       field_store_string(i_s_table->field[0],
441 +                               "XTRA_LRU_RESTORE was failed.");
442 +               }
443 +
444 +               goto end_func;
445 +       }
446  
447         field_store_string(i_s_table->field[0],
448                 "Undefined XTRA_* command.");
449 --- a/storage/innobase/include/buf0lru.h
450 +++ b/storage/innobase/include/buf0lru.h
451 @@ -204,6 +204,18 @@
452  void
453  buf_LRU_stat_update(void);
454  /*=====================*/
455 +/********************************************************************//**
456 +Dump the LRU page list to the specific file. */
457 +UNIV_INTERN
458 +ibool
459 +buf_LRU_file_dump(void);
460 +/*===================*/
461 +/********************************************************************//**
462 +Read the pages based on the specific file.*/
463 +UNIV_INTERN
464 +ibool
465 +buf_LRU_file_restore(void);
466 +/*======================*/
467  
468  #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
469  /**********************************************************************//**
470 --- a/storage/innobase/include/buf0rea.h
471 +++ b/storage/innobase/include/buf0rea.h
472 @@ -31,6 +31,37 @@
473  #include "buf0types.h"
474  
475  /********************************************************************//**
476 +Low-level function which reads a page asynchronously from a file to the
477 +buffer buf_pool if it is not already there, in which case does nothing.
478 +Sets the io_fix flag and sets an exclusive lock on the buffer frame. The
479 +flag is cleared and the x-lock released by an i/o-handler thread.
480 +@return 1 if a read request was queued, 0 if the page already resided
481 +in buf_pool, or if the page is in the doublewrite buffer blocks in
482 +which case it is never read into the pool, or if the tablespace does
483 +not exist or is being dropped 
484 +@return 1 if read request is issued. 0 if it is not */
485 +UNIV_INTERN
486 +ulint
487 +buf_read_page_low(
488 +/*==============*/
489 +       ulint*  err,    /*!< out: DB_SUCCESS or DB_TABLESPACE_DELETED if we are
490 +                       trying to read from a non-existent tablespace, or a
491 +                       tablespace which is just now being dropped */
492 +       ibool   sync,   /*!< in: TRUE if synchronous aio is desired */
493 +       ulint   mode,   /*!< in: BUF_READ_IBUF_PAGES_ONLY, ...,
494 +                       ORed to OS_AIO_SIMULATED_WAKE_LATER (see below
495 +                       at read-ahead functions) */
496 +       ulint   space,  /*!< in: space id */
497 +       ulint   zip_size,/*!< in: compressed page size, or 0 */
498 +       ibool   unzip,  /*!< in: TRUE=request uncompressed page */
499 +       ib_int64_t tablespace_version, /*!< in: if the space memory object has
500 +                       this timestamp different from what we are giving here,
501 +                       treat the tablespace as dropped; this is a timestamp we
502 +                       use to stop dangling page reads from a tablespace
503 +                       which we have DISCARDed + IMPORTed back */
504 +       ulint   offset, /*!< in: page number */
505 +       trx_t*  trx);
506 +/********************************************************************//**
507  High-level function which reads a page asynchronously from a file to the
508  buffer buf_pool if it is not already there. Sets the io_fix flag and sets
509  an exclusive lock on the buffer frame. The flag is cleared and the x-lock
510 --- a/storage/innobase/include/fil0fil.h
511 +++ b/storage/innobase/include/fil0fil.h
512 @@ -644,6 +644,14 @@
513         void*   message,        /*!< in: message for aio handler if non-sync
514                                 aio used, else ignored */
515         trx_t*  trx);
516 +/********************************************************************//**
517 +Confirm whether the parameters are valid or not */
518 +UNIV_INTERN
519 +ibool
520 +fil_is_exist(
521 +/*==============*/
522 +       ulint   space_id,       /*!< in: space id */
523 +       ulint   block_offset);  /*!< in: offset in number of blocks */
524  /**********************************************************************//**
525  Waits for an aio operation to complete. This function is used to write the
526  handler for completed requests. The aio array of pending requests is divided
527 --- a/storage/innobase/include/srv0srv.h
528 +++ b/storage/innobase/include/srv0srv.h
529 @@ -356,6 +356,9 @@
530  reading of a disk page */
531  extern ulint srv_buf_pool_reads;
532  
533 +/** Time in seconds between automatic buffer pool dumps */
534 +extern uint srv_auto_lru_dump;
535 +
536  /** Status variables to be passed to MySQL */
537  typedef struct export_var_struct export_struc;
538  
539 @@ -661,6 +664,16 @@
540  /*=====================*/
541         void*   arg);   /*!< in: a dummy parameter required by
542                         os_thread_create */
543 +/*********************************************************************//**
544 +A thread which restores the buffer pool from a dump file on startup and does
545 +periodic buffer pool dumps.
546 +@return        a dummy parameter */
547 +UNIV_INTERN
548 +os_thread_ret_t
549 +srv_LRU_dump_restore_thread(
550 +/*====================*/
551 +       void*   arg);   /*!< in: a dummy parameter required by
552 +                       os_thread_create */
553  /******************************************************************//**
554  Outputs to a file the output of the InnoDB Monitor.
555  @return FALSE if not all information printed
556 --- a/storage/innobase/srv/srv0srv.c
557 +++ b/storage/innobase/srv/srv0srv.c
558 @@ -330,6 +330,9 @@
559  reading of a disk page */
560  UNIV_INTERN ulint srv_buf_pool_reads = 0;
561  
562 +/** Time in seconds between automatic buffer pool dumps */
563 +UNIV_INTERN uint srv_auto_lru_dump = 0;
564 +
565  /* structure to pass status variables to MySQL */
566  UNIV_INTERN export_struc export_vars;
567  
568 @@ -2706,6 +2709,56 @@
569         OS_THREAD_DUMMY_RETURN;
570  }
571  
572 +/*********************************************************************//**
573 +A thread which restores the buffer pool from a dump file on startup and does
574 +periodic buffer pool dumps.
575 +@return        a dummy parameter */
576 +UNIV_INTERN
577 +os_thread_ret_t
578 +srv_LRU_dump_restore_thread(
579 +/*====================*/
580 +       void*   arg __attribute__((unused)))
581 +                       /*!< in: a dummy parameter required by
582 +                       os_thread_create */
583 +{
584 +       uint    auto_lru_dump;
585 +       time_t  last_dump_time;
586 +       time_t  time_elapsed;
587 +
588 +#ifdef UNIV_DEBUG_THREAD_CREATION
589 +       fprintf(stderr, "The LRU dump/restore thread has started, id %lu\n",
590 +               os_thread_pf(os_thread_get_curr_id()));
591 +#endif
592 +
593 +       if (srv_auto_lru_dump)
594 +               buf_LRU_file_restore();
595 +
596 +       last_dump_time = time(NULL);
597 +
598 +loop:
599 +       os_thread_sleep(5000000);
600 +
601 +       if (srv_shutdown_state >= SRV_SHUTDOWN_CLEANUP) {
602 +               goto exit_func;
603 +       }
604 +
605 +       time_elapsed = time(NULL) - last_dump_time;
606 +       auto_lru_dump = srv_auto_lru_dump;
607 +       if (auto_lru_dump > 0 && (time_t) auto_lru_dump < time_elapsed) {
608 +               last_dump_time = time(NULL);
609 +               buf_LRU_file_dump();
610 +       }
611 +
612 +       goto loop;
613 +exit_func:
614 +       /* We count the number of threads in os_thread_exit(). A created
615 +       thread should always use that to exit and not use return() to exit. */
616 +
617 +       os_thread_exit(NULL);
618 +
619 +       OS_THREAD_DUMMY_RETURN;
620 +}
621 +
622  /**********************************************************************//**
623  Check whether any background thread is active.
624  @return FALSE if all are are suspended or have exited. */
625 --- a/storage/innobase/srv/srv0start.c
626 +++ b/storage/innobase/srv/srv0start.c
627 @@ -120,9 +120,9 @@
628  static os_file_t       files[1000];
629  
630  /** io_handler_thread parameters for thread identification */
631 -static ulint           n[SRV_MAX_N_IO_THREADS + 6];
632 +static ulint           n[SRV_MAX_N_IO_THREADS + 7];
633  /** io_handler_thread identifiers */
634 -static os_thread_id_t  thread_ids[SRV_MAX_N_IO_THREADS + 6];
635 +static os_thread_id_t  thread_ids[SRV_MAX_N_IO_THREADS + 7];
636  
637  /** We use this mutex to test the return value of pthread_mutex_trylock
638     on successful locking. HP-UX does NOT return 0, though Linux et al do. */
639 @@ -1821,6 +1821,10 @@
640         os_thread_create(&srv_monitor_thread, NULL,
641                          thread_ids + 4 + SRV_MAX_N_IO_THREADS);
642  
643 +       /* Create the thread which automaticaly dumps/restore buffer pool */
644 +       os_thread_create(&srv_LRU_dump_restore_thread, NULL,
645 +                        thread_ids + 5 + SRV_MAX_N_IO_THREADS);
646 +
647         srv_is_being_started = FALSE;
648  
649         err = dict_create_or_check_foreign_constraint_tables();
This page took 0.132085 seconds and 4 git commands to generate.