1 diff -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
8 -#ifndef UNIV_HOTBACKUP
10 if (recv_lsn_checks_on && log_peek_lsn(¤t_lsn)) {
11 if (ut_dulint_cmp(current_lsn,
12 mach_read_from_8(read_buf + FIL_PAGE_LSN))
13 diff -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
17 block = buf_page_init_for_read(err, mode, space, tablespace_version,
20 + if (recv_recovery_is_on() && *err == DB_TABLESPACE_DELETED) {
21 + /* hashed log recs must be treated here */
22 + recv_addr_t* recv_addr;
24 + mutex_enter(&(recv_sys->mutex));
26 + if (recv_sys->apply_log_recs == FALSE) {
27 + mutex_exit(&(recv_sys->mutex));
28 + goto not_to_recover;
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));
36 + if ((recv_addr->space == space)
37 + && (recv_addr->page_no == offset)) {
40 + recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
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;
50 + fprintf(stderr, " (space:%lu is deleted)", space);
51 + recv_addr->state = RECV_PROCESSED;
53 + ut_a(recv_sys->n_addrs);
54 + recv_sys->n_addrs--;
56 + mutex_exit(&(recv_sys->mutex));
63 while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) {
65 os_aio_simulated_wake_handler_threads();
66 - os_thread_sleep(500000);
67 + os_thread_sleep(20000);
74 "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n"
75 "InnoDB: reads to the buffer pool to be finished.\n"
76 diff -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
83 -#ifndef UNIV_HOTBACKUP
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
90 mutex_exit(&(system->mutex));
92 -#ifndef UNIV_HOTBACKUP
99 fil_node_create(path, size, *space_id, FALSE);
101 -#ifndef UNIV_HOTBACKUP
106 @@ -2890,7 +2890,7 @@
109 size = (((ib_longlong)size_high) << 32) + (ib_longlong)size_low;
110 -#ifndef UNIV_HOTBACKUP
112 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
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. */
122 fil_file_readdir_next_file(
123 /*=======================*/
124 @@ -3949,6 +3949,16 @@
126 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
128 + if (space->size <= block_offset) {
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. */
138 node = UT_LIST_GET_FIRST(space->chain);
141 diff -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
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
152 diff -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
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;
161 #ifdef UNIV_MEM_DEBUG
165 ut_ad(mem_heap_check(heap));
170 while (block != NULL) {
172 size += mem_block_get_len(block);
173 block = UT_LIST_GET_NEXT(list, block);
176 + size = heap->sum_len;
178 if (heap->free_block) {
179 size += UNIV_PAGE_SIZE;
180 diff -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
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;
190 void set_panic_flag_for_netware(void);
191 diff -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
195 dulint a, /* in: dulint */
196 ulint b) /* in: ulint */
198 + if (sizeof(ulint) != 4) {
206 if (0xFFFFFFFFUL - b >= a.low) {
210 dulint a, /* in: dulint */
211 ulint b) /* in: ulint, b <= a */
213 + if (sizeof(ulint) != 4) {
229 + if (sizeof(ulint) != 4) {
230 + diff += (a.high - b.high - 1) << 32;
235 diff -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
240 offset = (gr_lsn_size_offset + difference) % group_size;
242 + if (sizeof(ulint) == 4) {
243 ut_a(offset < (((ib_longlong) 1) << 32)); /* offset must be < 4 GB */
247 "Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
248 diff -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
253 #include "sync0sync.h"
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 */
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))
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
272 recv_sys_t* recv_sys = NULL;
273 ibool recv_recovery_on = FALSE;
275 use these free frames to read in pages when we start applying the
276 log records to the database. */
278 -ulint recv_n_pool_free_frames = 256;
279 +ulint recv_n_pool_free_frames = 1024;
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
285 /***************************************************************************
286 Checks the consistency of the checkpoint info */
290 recv_check_cp_is_consistent(
291 /*========================*/
294 /************************************************************
295 Looks for the maximum consistent checkpoint from the log groups. */
299 recv_find_max_checkpoint(
300 /*=====================*/
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. */
308 log_block_checksum_is_ok_or_old_format(
309 /*===================================*/
310 @@ -1135,6 +1135,7 @@
311 recv_addr = recv_get_fil_addr_struct(space, page_no);
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)) {
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) {
326 /* In ibbackup --apply-log, replay an .ibd file
327 @@ -2093,7 +2094,7 @@
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)) {
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)
351 @@ -2626,12 +2630,14 @@
353 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
357 "InnoDB: Restoring possible"
358 " half-written data pages from"
360 "InnoDB: buffer...\n");
361 - trx_sys_doublewrite_init_or_restore_pages(TRUE);
363 + trx_sys_doublewrite_init_or_restore_pages(FALSE);
367 @@ -2760,6 +2766,7 @@
368 recv_sys->recovered_lsn = checkpoint_lsn;
370 srv_start_lsn = checkpoint_lsn;
371 + srv_oldest_lsn = checkpoint_lsn;
374 contiguous_lsn = ut_dulint_align_down(recv_sys->scanned_lsn,
375 diff -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
379 /* Add the new block as the last block */
381 UT_LIST_INSERT_AFTER(list, heap->base, block, new_block);
382 + heap->sum_len += new_block->len;
389 UT_LIST_REMOVE(list, heap->base, block);
390 + heap->sum_len -= block->len;
392 #ifdef MEM_PERIODIC_CHECK
393 mem_pool_mutex_enter();
394 diff -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
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.
406 @@ -3148,6 +3148,13 @@
407 struct aiocb* control;
410 + ulint prim_segment;
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);
418 os_mutex_enter(array->mutex);
420 @@ -3166,6 +3173,16 @@
424 + for (i = prim_segment * n; i < array->n_slots; i++) {
425 + slot = os_aio_array_get_nth_slot(array, i);
427 + if (slot->reserved == FALSE) {
432 + if (slot->reserved == TRUE){
433 + /* Not found after the intended segment. So we should search before. */
435 slot = os_aio_array_get_nth_slot(array, i);
437 @@ -3173,6 +3190,7 @@
445 diff -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__)
452 + /* select() simetimes hang up from xtrabackup */
453 + /* change to use usleep() for now */
458 t.tv_sec = tm / 1000000;
459 t.tv_usec = tm % 1000000;
461 select(0, NULL, NULL, NULL, &t);
466 diff -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
470 /* Log sequence number at shutdown */
471 dulint srv_shutdown_lsn;
473 +dulint srv_oldest_lsn;
475 #ifdef HAVE_DARWIN_THREADS
476 # include <sys/utsname.h>
477 ibool srv_have_fullfsync = FALSE;
479 #ifndef UNIV_HOTBACKUP
480 /*************************************************************************
481 Creates or opens the log files and closes them. */
485 open_or_create_log_file(
486 /*====================*/
489 /*************************************************************************
490 Creates or opens database data files and closes them. */
494 open_or_create_data_files(
495 /*======================*/
496 @@ -1213,12 +1215,12 @@
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;*/
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);
509 os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
510 * srv_n_file_io_threads,
511 @@ -1275,7 +1277,7 @@
513 #endif /* UNIV_LOG_ARCHIVE */
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) {
518 "InnoDB: Error: combined size of log files must be < 4 GB\n");
520 @@ -1609,7 +1611,18 @@
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 */
526 + fil_extend_space_to_desired_size(&actual_size, 0, tablespace_size_in_header);
527 + if (actual_size < tablespace_size_in_header) {
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);
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 @@
546 /* Check that os_fast_mutexes work as expected */
547 diff -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
551 ut_dulint_get_low(trx->id));
553 if (srv_force_recovery == 0) {
555 - trx->conc_state = TRX_PREPARED;
556 + /* xtrabackup should rollback it */
557 + trx->conc_state = TRX_ACTIVE;
560 "InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n");
562 ut_dulint_get_low(trx->id));
564 if (srv_force_recovery == 0) {
566 - trx->conc_state = TRX_PREPARED;
567 + /* xtrabackup should rollback it */
568 + trx->conc_state = TRX_ACTIVE;
571 "InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n");