]> git.pld-linux.org Git - packages/mysql.git/blame - mysql-xtrabackup.patch
- update from ourdelta patches: sphinxsearch/sphinx_engine/sphinx.5.0.86.patch
[packages/mysql.git] / mysql-xtrabackup.patch
CommitLineData
45532174
ER
1diff -ru a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
2--- a/innobase/buf/buf0buf.c 2008-12-19 02:19:35.000000000 +0900
3+++ b/innobase/buf/buf0buf.c 2009-04-08 10:52:42.000000000 +0900
4@@ -314,7 +314,7 @@
5 return(TRUE);
6 }
7
8-#ifndef UNIV_HOTBACKUP
9+#ifdef UNDEFINED
10 if (recv_lsn_checks_on && log_peek_lsn(&current_lsn)) {
11 if (ut_dulint_cmp(current_lsn,
12 mach_read_from_8(read_buf + FIL_PAGE_LSN))
13diff -ru a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
14--- a/innobase/buf/buf0rea.c 2008-12-19 02:19:35.000000000 +0900
15+++ b/innobase/buf/buf0rea.c 2009-04-09 18:18:30.000000000 +0900
16@@ -125,6 +125,45 @@
17 block = buf_page_init_for_read(err, mode, space, tablespace_version,
18 offset);
19 if (block == NULL) {
20+ if (recv_recovery_is_on() && *err == DB_TABLESPACE_DELETED) {
21+ /* hashed log recs must be treated here */
22+ recv_addr_t* recv_addr;
23+
24+ mutex_enter(&(recv_sys->mutex));
25+
26+ if (recv_sys->apply_log_recs == FALSE) {
27+ mutex_exit(&(recv_sys->mutex));
28+ goto not_to_recover;
29+ }
30+
31+ /* recv_get_fil_addr_struct() */
32+ recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
33+ hash_calc_hash(ut_fold_ulint_pair(space, offset),
34+ recv_sys->addr_hash));
35+ while (recv_addr) {
36+ if ((recv_addr->space == space)
37+ && (recv_addr->page_no == offset)) {
38+ break;
39+ }
40+ recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
41+ }
42+
43+ if ((recv_addr == NULL)
44+ || (recv_addr->state == RECV_BEING_PROCESSED)
45+ || (recv_addr->state == RECV_PROCESSED)) {
46+ mutex_exit(&(recv_sys->mutex));
47+ goto not_to_recover;
48+ }
49+
50+ fprintf(stderr, " (space:%lu is deleted)", space);
51+ recv_addr->state = RECV_PROCESSED;
52+
53+ ut_a(recv_sys->n_addrs);
54+ recv_sys->n_addrs--;
55+
56+ mutex_exit(&(recv_sys->mutex));
57+ }
58+not_to_recover:
59
60 return(0);
61 }
62@@ -684,11 +723,11 @@
63 while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) {
64
65 os_aio_simulated_wake_handler_threads();
66- os_thread_sleep(500000);
67+ os_thread_sleep(20000);
68
69 count++;
70
71- if (count > 100) {
72+ if (count > 2500) {
73 fprintf(stderr,
74 "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n"
75 "InnoDB: reads to the buffer pool to be finished.\n"
76diff -ru a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
77--- a/innobase/fil/fil0fil.c 2008-12-19 02:19:35.000000000 +0900
78+++ b/innobase/fil/fil0fil.c 2009-04-08 10:52:42.000000000 +0900
79@@ -2027,7 +2027,7 @@
80 }
81
82 if (success) {
83-#ifndef UNIV_HOTBACKUP
84+#ifdef UNDEFINED
85 /* Write a log record about the deletion of the .ibd
86 file, so that ibbackup can replay it in the
87 --apply-log phase. We use a dummy mtr and the familiar
88@@ -2300,7 +2300,7 @@
89
90 mutex_exit(&(system->mutex));
91
92-#ifndef UNIV_HOTBACKUP
93+#ifdef UNDEFINED
94 if (success) {
95 mtr_t mtr;
96
97@@ -2471,7 +2471,7 @@
98
99 fil_node_create(path, size, *space_id, FALSE);
100
101-#ifndef UNIV_HOTBACKUP
102+#ifdef UNDEFINED
103 {
104 mtr_t mtr;
105
106@@ -2890,7 +2890,7 @@
107 cannot be ok. */
108
109 size = (((ib_longlong)size_high) << 32) + (ib_longlong)size_low;
110-#ifndef UNIV_HOTBACKUP
111+#ifdef UNDEFINED
112 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
113 fprintf(stderr,
114 "InnoDB: Error: the size of single-table tablespace file %s\n"
115@@ -3009,7 +3009,7 @@
116 A fault-tolerant function that tries to read the next file name in the
117 directory. We retry 100 times if os_file_readdir_next_file() returns -1. The
118 idea is to read as much good data as we can and jump over bad data. */
119-static
120+//static
121 int
122 fil_file_readdir_next_file(
123 /*=======================*/
124@@ -3949,6 +3949,16 @@
125
126 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
127
128+ if (space->size <= block_offset) {
129+ ulint actual_size;
130+
131+ mutex_exit(&(system->mutex));
132+ fil_extend_space_to_desired_size(&actual_size, space->id,
133+ ((block_offset + 1) / 64 + 1) * 64);
134+ mutex_enter(&(system->mutex));
135+ /* should retry? but it may safe for xtrabackup for now. */
136+ }
137+
138 node = UT_LIST_GET_FIRST(space->chain);
139
140 for (;;) {
141diff -ru a/innobase/include/mem0mem.h b/innobase/include/mem0mem.h
142--- a/innobase/include/mem0mem.h 2008-12-19 02:19:36.000000000 +0900
143+++ b/innobase/include/mem0mem.h 2009-04-08 10:52:42.000000000 +0900
144@@ -352,6 +352,7 @@
145 allocated buffer frame, which can be appended as a
146 free block to the heap, if we need more space;
147 otherwise, this is NULL */
148+ ulint sum_len; /* sum of all blocks' len belong to the base node */
149 #ifdef MEM_PERIODIC_CHECK
150 UT_LIST_NODE_T(mem_block_t) mem_block_list;
151 /* List of all mem blocks allocated; protected
152diff -ru a/innobase/include/mem0mem.ic b/innobase/include/mem0mem.ic
153--- a/innobase/include/mem0mem.ic 2008-12-19 02:19:36.000000000 +0900
154+++ b/innobase/include/mem0mem.ic 2009-04-08 10:52:42.000000000 +0900
155@@ -415,6 +415,7 @@
156
157 /* Add the created block itself as the first block in the list */
158 UT_LIST_ADD_FIRST(list, block->base, block);
159+ block->sum_len = block->len;
160
161 #ifdef UNIV_MEM_DEBUG
162
163@@ -546,6 +547,7 @@
164
165 ut_ad(mem_heap_check(heap));
166
167+/*
168 block = heap;
169
170 while (block != NULL) {
171@@ -553,6 +555,8 @@
172 size += mem_block_get_len(block);
173 block = UT_LIST_GET_NEXT(list, block);
174 }
175+*/
176+ size = heap->sum_len;
177
178 if (heap->free_block) {
179 size += UNIV_PAGE_SIZE;
180diff -ru a/innobase/include/srv0start.h b/innobase/include/srv0start.h
181--- a/innobase/include/srv0start.h 2008-12-19 02:19:36.000000000 +0900
182+++ b/innobase/include/srv0start.h 2009-04-08 10:52:42.000000000 +0900
183@@ -80,6 +80,7 @@
184 /* out: DB_SUCCESS or error code */
185 extern dulint srv_shutdown_lsn;
186 extern dulint srv_start_lsn;
187+extern dulint srv_oldest_lsn;
188
189 #ifdef __NETWARE__
190 void set_panic_flag_for_netware(void);
191diff -ru a/innobase/include/ut0byte.ic b/innobase/include/ut0byte.ic
192--- a/innobase/include/ut0byte.ic 2008-12-19 02:19:36.000000000 +0900
193+++ b/innobase/include/ut0byte.ic 2009-04-08 10:52:42.000000000 +0900
194@@ -152,6 +152,14 @@
195 dulint a, /* in: dulint */
196 ulint b) /* in: ulint */
197 {
198+ if (sizeof(ulint) != 4) {
199+ ulint b_h;
200+
201+ b_h = b >> 32;
202+ b &= 0xFFFFFFFFUL;
203+ a.high += b_h;
204+ }
205+
206 if (0xFFFFFFFFUL - b >= a.low) {
207 a.low += b;
208
209@@ -175,6 +183,14 @@
210 dulint a, /* in: dulint */
211 ulint b) /* in: ulint, b <= a */
212 {
213+ if (sizeof(ulint) != 4) {
214+ ulint b_h;
215+
216+ b_h = b >> 32;
217+ b &= 0xFFFFFFFFUL;
218+ a.high -= b_h;
219+ }
220+
221 if (a.low >= b) {
222 a.low -= b;
223
224@@ -218,6 +234,10 @@
225 diff += 1 + a.low;
226
227 ut_ad(diff > a.low);
228+
229+ if (sizeof(ulint) != 4) {
230+ diff += (a.high - b.high - 1) << 32;
231+ }
232
233 return(diff);
234 }
235diff -ru a/innobase/log/log0log.c b/innobase/log/log0log.c
236--- a/innobase/log/log0log.c 2008-12-19 02:19:36.000000000 +0900
237+++ b/innobase/log/log0log.c 2009-04-08 10:52:42.000000000 +0900
238@@ -548,7 +548,9 @@
239
240 offset = (gr_lsn_size_offset + difference) % group_size;
241
242+ if (sizeof(ulint) == 4) {
243 ut_a(offset < (((ib_longlong) 1) << 32)); /* offset must be < 4 GB */
244+ }
245
246 /* fprintf(stderr,
247 "Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
248diff -ru a/innobase/log/log0recv.c b/innobase/log/log0recv.c
249--- a/innobase/log/log0recv.c 2008-12-19 02:19:36.000000000 +0900
250+++ b/innobase/log/log0recv.c 2009-04-09 18:34:45.000000000 +0900
251@@ -35,19 +35,19 @@
252 #include "fil0fil.h"
253 #include "sync0sync.h"
254
255-#ifdef UNIV_HOTBACKUP
256+//#ifdef UNIV_HOTBACKUP
257 /* This is set to FALSE if the backup was originally taken with the
258 ibbackup --include regexp option: then we do not want to create tables in
259 directories which were not included */
260 ibool recv_replay_file_ops = TRUE;
261-#endif /* UNIV_HOTBACKUP */
262+//#endif /* UNIV_HOTBACKUP */
263
264 /* Log records are stored in the hash table in chunks at most of this size;
265 this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
266 #define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
267
268 /* Read-ahead area in applying log records to file pages */
269-#define RECV_READ_AHEAD_AREA 32
270+#define RECV_READ_AHEAD_AREA 128
271
272 recv_sys_t* recv_sys = NULL;
273 ibool recv_recovery_on = FALSE;
274@@ -101,7 +101,7 @@
275 use these free frames to read in pages when we start applying the
276 log records to the database. */
277
278-ulint recv_n_pool_free_frames = 256;
279+ulint recv_n_pool_free_frames = 1024;
280
281 /* The maximum lsn we see for a page during the recovery process. If this
282 is bigger than the lsn we are able to scan up to, that is an indication that
283@@ -450,7 +450,7 @@
284
285 /***************************************************************************
286 Checks the consistency of the checkpoint info */
287-static
288+//static
289 ibool
290 recv_check_cp_is_consistent(
291 /*========================*/
347e7259 292@@ -479,7 +479,7 @@
45532174 293
347e7259
ER
294 /************************************************************
295 Looks for the maximum consistent checkpoint from the log groups. */
296-static
297+//static
298 ulint
299 recv_find_max_checkpoint(
300 /*=====================*/
301@@ -644,7 +644,7 @@
302 Checks the 4-byte checksum to the trailer checksum field of a log block.
303 We also accept a log block in the old format < InnoDB-3.23.52 where the
304 checksum field contains the log block number. */
305-static
306+//static
307 ibool
308 log_block_checksum_is_ok_or_old_format(
309 /*===================================*/
45532174
ER
310@@ -1135,6 +1135,7 @@
311 recv_addr = recv_get_fil_addr_struct(space, page_no);
312
313 if ((recv_addr == NULL)
314+ || (recv_addr->state == RECV_BEING_READ && !just_read_in)
315 || (recv_addr->state == RECV_BEING_PROCESSED)
316 || (recv_addr->state == RECV_PROCESSED)) {
317
318@@ -2076,7 +2077,7 @@
319 } else if (store_to_hash && (type == MLOG_FILE_CREATE
320 || type == MLOG_FILE_RENAME
321 || type == MLOG_FILE_DELETE)) {
322-#ifdef UNIV_HOTBACKUP
323+//#ifdef UNIV_HOTBACKUP
324 if (recv_replay_file_ops) {
325
326 /* In ibbackup --apply-log, replay an .ibd file
327@@ -2093,7 +2094,7 @@
328 ut_a(0);
329 }
330 }
331-#endif
332+//#endif
333 /* In normal mysqld crash recovery we do not try to
334 replay file operations */
335 } else if (store_to_hash) {
336@@ -2514,9 +2515,12 @@
337 if (finished || (recv_scan_print_counter % 80 == 0)) {
338
339 fprintf(stderr,
340-"InnoDB: Doing recovery: scanned up to log sequence number %lu %lu\n",
341+"InnoDB: Doing recovery: scanned up to log sequence number %lu %lu (%lu %)\n",
342 (ulong) ut_dulint_get_high(*group_scanned_lsn),
343- (ulong) ut_dulint_get_low(*group_scanned_lsn));
344+ (ulong) ut_dulint_get_low(*group_scanned_lsn),
345+ (ulong) ut_dulint_minus(*group_scanned_lsn, srv_oldest_lsn)
346+ / (8 * log_group_get_capacity(UT_LIST_GET_FIRST(log_sys->log_groups))/900)
347+ );
348 }
349 }
350
351@@ -2626,12 +2630,14 @@
352
353 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
354
355+#ifdef UNDEFINED
356 fprintf(stderr,
357 "InnoDB: Restoring possible"
358 " half-written data pages from"
359 " the doublewrite\n"
360 "InnoDB: buffer...\n");
361- trx_sys_doublewrite_init_or_restore_pages(TRUE);
362+#endif
363+ trx_sys_doublewrite_init_or_restore_pages(FALSE);
364 }
365
366 }
367@@ -2760,6 +2766,7 @@
368 recv_sys->recovered_lsn = checkpoint_lsn;
369
370 srv_start_lsn = checkpoint_lsn;
371+ srv_oldest_lsn = checkpoint_lsn;
372 }
373
374 contiguous_lsn = ut_dulint_align_down(recv_sys->scanned_lsn,
375diff -ru a/innobase/mem/mem0mem.c b/innobase/mem/mem0mem.c
376--- a/innobase/mem/mem0mem.c 2008-12-19 02:19:36.000000000 +0900
377+++ b/innobase/mem/mem0mem.c 2009-04-08 10:52:42.000000000 +0900
378@@ -266,6 +266,7 @@
379 /* Add the new block as the last block */
380
381 UT_LIST_INSERT_AFTER(list, heap->base, block, new_block);
382+ heap->sum_len += new_block->len;
383
384 return(new_block);
385 }
386@@ -288,6 +289,7 @@
387 }
388
389 UT_LIST_REMOVE(list, heap->base, block);
390+ heap->sum_len -= block->len;
391
392 #ifdef MEM_PERIODIC_CHECK
393 mem_pool_mutex_enter();
394diff -ru a/innobase/os/os0file.c b/innobase/os/os0file.c
395--- a/innobase/os/os0file.c 2008-12-19 02:19:36.000000000 +0900
396+++ b/innobase/os/os0file.c 2009-04-09 18:22:49.000000000 +0900
347e7259
ER
397@@ -435,7 +435,7 @@
398 }
45532174 399
347e7259
ER
400 #undef USE_FILE_LOCK
401-#define USE_FILE_LOCK
402+//#define USE_FILE_LOCK
403 #if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__NETWARE__)
404 /* InnoDB Hot Backup does not lock the data files.
405 * On Windows, mandatory locking is used.
45532174
ER
406@@ -3148,6 +3148,13 @@
407 struct aiocb* control;
408 #endif
409 ulint i;
410+ ulint prim_segment;
411+ ulint n;
412+
413+ n = array->n_slots / array->n_segments;
414+ /* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
415+ prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
416+
417 loop:
418 os_mutex_enter(array->mutex);
419
420@@ -3166,6 +3173,16 @@
421 goto loop;
422 }
423
424+ for (i = prim_segment * n; i < array->n_slots; i++) {
425+ slot = os_aio_array_get_nth_slot(array, i);
426+
427+ if (slot->reserved == FALSE) {
428+ break;
429+ }
430+ }
431+
432+ if (slot->reserved == TRUE){
433+ /* Not found after the intended segment. So we should search before. */
434 for (i = 0;; i++) {
435 slot = os_aio_array_get_nth_slot(array, i);
436
437@@ -3173,6 +3190,7 @@
438 break;
439 }
440 }
441+ }
442
443 array->n_reserved++;
444
445diff -ru a/innobase/os/os0thread.c b/innobase/os/os0thread.c
446--- a/innobase/os/os0thread.c 2008-12-19 02:19:36.000000000 +0900
447+++ b/innobase/os/os0thread.c 2009-04-08 10:52:42.000000000 +0900
448@@ -266,12 +266,17 @@
449 #elif defined(__NETWARE__)
450 delay(tm / 1000);
451 #else
452+ /* select() simetimes hang up from xtrabackup */
453+ /* change to use usleep() for now */
454+ usleep(tm);
455+/*
456 struct timeval t;
457
458 t.tv_sec = tm / 1000000;
459 t.tv_usec = tm % 1000000;
460
461 select(0, NULL, NULL, NULL, &t);
462+*/
463 #endif
464 }
465
466diff -ru a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
467--- a/innobase/srv/srv0start.c 2008-12-19 02:19:37.000000000 +0900
468+++ b/innobase/srv/srv0start.c 2009-04-09 18:25:02.000000000 +0900
469@@ -61,6 +61,8 @@
470 /* Log sequence number at shutdown */
471 dulint srv_shutdown_lsn;
472
473+dulint srv_oldest_lsn;
474+
475 #ifdef HAVE_DARWIN_THREADS
476 # include <sys/utsname.h>
477 ibool srv_have_fullfsync = FALSE;
478@@ -547,7 +549,7 @@
347e7259
ER
479 #ifndef UNIV_HOTBACKUP
480 /*************************************************************************
481 Creates or opens the log files and closes them. */
482-static
483+//static
484 ulint
485 open_or_create_log_file(
486 /*====================*/
45532174
ER
487@@ -693,7 +695,7 @@
488
347e7259
ER
489 /*************************************************************************
490 Creates or opens database data files and closes them. */
491-static
492+//static
493 ulint
494 open_or_create_data_files(
495 /*======================*/
45532174
ER
496@@ -1213,12 +1215,12 @@
497
498 if (!os_aio_use_native_aio) {
499 /* In simulated aio we currently have use only for 4 threads */
500- srv_n_file_io_threads = 4;
501+ /*srv_n_file_io_threads = 4;*/
502
503 os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
504 * srv_n_file_io_threads,
505 srv_n_file_io_threads,
506- SRV_MAX_N_PENDING_SYNC_IOS);
507+ SRV_MAX_N_PENDING_SYNC_IOS * 8);
508 } else {
509 os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
510 * srv_n_file_io_threads,
511@@ -1275,7 +1277,7 @@
512 }
513 #endif /* UNIV_LOG_ARCHIVE */
514
515- if (srv_n_log_files * srv_log_file_size >= 262144) {
516+ if (sizeof(ulint) == 4 && srv_n_log_files * srv_log_file_size >= 262144) {
517 fprintf(stderr,
518 "InnoDB: Error: combined size of log files must be < 4 GB\n");
519
520@@ -1609,7 +1611,18 @@
521
522 if (srv_auto_extend_last_data_file
523 && sum_of_data_file_sizes < tablespace_size_in_header) {
524+ /* extend table space size aligning with header */
525+ ulint actual_size;
526+ fil_extend_space_to_desired_size(&actual_size, 0, tablespace_size_in_header);
527+ if (actual_size < tablespace_size_in_header) {
347e7259 528+ fprintf(stderr,
45532174
ER
529+"InnoDB: Warning: To extend tablespace size aligning with header seems to be failed.\n"
530+"InnoDB: The acutual size %lu must be larger than %lu.\n",
531+ (ulong) actual_size,
532+ (ulong) tablespace_size_in_header);
347e7259 533+ }
45532174
ER
534
535+#ifdef UNDEFINED
536 fprintf(stderr,
537 "InnoDB: Error: tablespace size stored in header is %lu pages, but\n"
538 "InnoDB: the sum of data file sizes is only %lu pages\n",
539@@ -1627,6 +1640,7 @@
540
541 return(DB_ERROR);
542 }
347e7259 543+#endif
45532174
ER
544 }
545
546 /* Check that os_fast_mutexes work as expected */
547diff -ru a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
548--- a/innobase/trx/trx0trx.c 2008-12-19 02:19:37.000000000 +0900
549+++ b/innobase/trx/trx0trx.c 2009-06-18 09:56:54.000000000 +0900
550@@ -486,8 +486,8 @@
551 ut_dulint_get_low(trx->id));
552
553 if (srv_force_recovery == 0) {
554-
555- trx->conc_state = TRX_PREPARED;
556+ /* xtrabackup should rollback it */
557+ trx->conc_state = TRX_ACTIVE;
558 } else {
559 fprintf(stderr,
560 "InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n");
561@@ -555,8 +555,8 @@
562 ut_dulint_get_low(trx->id));
563
564 if (srv_force_recovery == 0) {
565-
566- trx->conc_state = TRX_PREPARED;
567+ /* xtrabackup should rollback it */
568+ trx->conc_state = TRX_ACTIVE;
569 } else {
570 fprintf(stderr,
571 "InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n");
This page took 0.175094 seconds and 4 git commands to generate.