1
--- a/storage/innobase/btr/btr0btr.c 2011-03-15 07:56:04.000000000 -0700
2
+++ b/storage/innobase/btr/btr0btr.c 2011-03-15 07:56:47.000000000 -0700
4
/**************************************************************//**
5
Gets the root node of a tree and x-latches it.
6
@return root page, x-latched */
13
/************************************************************//**
14
Returns the child page of a node pointer and x-latches it.
15
@return child page, x-latched */
19
btr_node_ptr_get_child(
20
/*===================*/
21
--- a/storage/innobase/buf/buf0buf.c 2011-03-15 07:56:04.000000000 -0700
22
+++ b/storage/innobase/buf/buf0buf.c 2011-03-15 07:56:47.000000000 -0700
27
-#ifndef UNIV_HOTBACKUP
29
if (recv_lsn_checks_on) {
30
ib_uint64_t current_lsn;
33
recv_recover_page(TRUE, (buf_block_t*) bpage);
36
- if (uncompressed && !recv_no_ibuf_operations) {
37
+ if (uncompressed && !recv_no_ibuf_operations && !srv_fake_write) {
38
ibuf_merge_or_delete_for_page(
39
/* Delete possible entries, if bpage is_corrupt */
40
(srv_pass_corrupt_table && bpage->is_corrupt) ? NULL :
41
--- a/storage/innobase/fil/fil0fil.c 2011-03-15 07:56:04.000000000 -0700
42
+++ b/storage/innobase/fil/fil0fil.c 2011-03-15 07:56:47.000000000 -0700
45
/** The tablespace memory cache. This variable is NULL before the module is
47
-static fil_system_t* fil_system = NULL;
48
+fil_system_t* fil_system = NULL;
51
/** Try fil_validate() every this many times */
53
off the LRU list if it is in the LRU list. The caller must hold the fil_sys
58
fil_node_prepare_for_io(
59
/*====================*/
60
fil_node_t* node, /*!< in: file node */
62
Opens a the file of a node of a tablespace. The caller must own the fil_system
69
fil_node_t* node, /*!< in: file node */
71
OS_FILE_READ_ONLY, &success);
73
/* The following call prints an error message */
74
- os_file_get_last_error(TRUE);
75
+ if (os_file_get_last_error(TRUE) == OS_FILE_NOT_FOUND)
77
+ ut_print_timestamp(stderr);
79
+ " InnoDB: Warning: cannot open %s\n",
81
+ return(OS_FILE_NOT_FOUND);
84
ut_print_timestamp(stderr);
89
if (size_bytes >= 1024 * 1024) {
90
- /* Truncate the size to whole megabytes. */
91
- size_bytes = ut_2pow_round(size_bytes, 1024 * 1024);
92
+ /* The size should be exact for after applying .delta */
93
+ //size_bytes = ut_2pow_round(size_bytes, 1024 * 1024);
96
if (!(flags & DICT_TF_ZSSIZE_MASK)) {
98
/* Put the node to the LRU list */
99
UT_LIST_ADD_FIRST(LRU, system->LRU, node);
105
/**********************************************************************//**
106
@@ -1474,7 +1483,12 @@
107
the file yet; the following calls will open it and update the
110
- fil_node_prepare_for_io(node, fil_system, space);
111
+ if (fil_node_prepare_for_io(node, fil_system, space))
113
+ mutex_exit(&fil_system->mutex);
117
fil_node_complete_io(node, fil_system, OS_FILE_READ);
120
@@ -1526,7 +1540,12 @@
121
the file yet; the following calls will open it and update the
124
- fil_node_prepare_for_io(node, fil_system, space);
125
+ if (fil_node_prepare_for_io(node, fil_system, space))
127
+ mutex_exit(&fil_system->mutex);
129
+ return(ULINT_UNDEFINED);
131
fil_node_complete_io(node, fil_system, OS_FILE_READ);
134
@@ -2202,7 +2221,7 @@
135
if (fil_create_new_single_table_tablespace(
136
space_id, name, FALSE, flags,
137
FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) {
143
@@ -2369,7 +2388,7 @@
147
-#ifndef UNIV_HOTBACKUP
149
/* Write a log record about the deletion of the .ibd
150
file, so that ibbackup can replay it in the
151
--apply-log phase. We use a dummy mtr and the familiar
152
@@ -2670,7 +2689,7 @@
154
mutex_exit(&fil_system->mutex);
156
-#ifndef UNIV_HOTBACKUP
161
@@ -2861,7 +2880,7 @@
163
fil_node_create(path, size, space_id, FALSE);
165
-#ifndef UNIV_HOTBACKUP
170
@@ -3116,19 +3135,97 @@
171
"InnoDB: open the tablespace file ", stderr);
172
ut_print_filename(stderr, filepath);
174
- "InnoDB: Have you moved InnoDB .ibd files around"
175
- " without using the\n"
176
- "InnoDB: commands DISCARD TABLESPACE and"
177
- " IMPORT TABLESPACE?\n"
178
- "InnoDB: It is also possible that this is"
179
- " a temporary table #sql...,\n"
180
- "InnoDB: and MySQL removed the .ibd file for this.\n"
181
- "InnoDB: Please refer to\n"
182
- "InnoDB: " REFMAN "innodb-troubleshooting-datadict.html\n"
183
- "InnoDB: for how to resolve the issue.\n", stderr);
184
+ "InnoDB: It will be removed from data dictionary.\n"
189
+ /* removing from data dictionary */
192
+ pars_info_t* info = NULL;
194
+ trx = trx_allocate_for_mysql();
196
+ trx->op_info = "removing invalid table from data dictionary";
198
+ info = pars_info_create();
200
+ pars_info_add_str_literal(info, "table_name", name);
203
+ "PROCEDURE DROP_TABLE_PROC () IS\n"
204
+ "sys_foreign_id CHAR;\n"
207
+ "foreign_id CHAR;\n"
210
+ "SELECT ID INTO table_id\n"
211
+ "FROM SYS_TABLES\n"
212
+ "WHERE NAME = :table_name\n"
213
+ "LOCK IN SHARE MODE;\n"
214
+ "IF (SQL % NOTFOUND) THEN\n"
218
+ "SELECT ID INTO sys_foreign_id\n"
219
+ "FROM SYS_TABLES\n"
220
+ "WHERE NAME = 'SYS_FOREIGN'\n"
221
+ "LOCK IN SHARE MODE;\n"
222
+ "IF (SQL % NOTFOUND) THEN\n"
225
+ "IF (:table_name = 'SYS_FOREIGN') THEN\n"
228
+ "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n"
231
+ "WHILE found = 1 LOOP\n"
232
+ " SELECT ID INTO foreign_id\n"
233
+ " FROM SYS_FOREIGN\n"
234
+ " WHERE FOR_NAME = :table_name\n"
235
+ " AND TO_BINARY(FOR_NAME)\n"
236
+ " = TO_BINARY(:table_name)\n"
237
+ " LOCK IN SHARE MODE;\n"
238
+ " IF (SQL % NOTFOUND) THEN\n"
241
+ " DELETE FROM SYS_FOREIGN_COLS\n"
242
+ " WHERE ID = foreign_id;\n"
243
+ " DELETE FROM SYS_FOREIGN\n"
244
+ " WHERE ID = foreign_id;\n"
248
+ "WHILE found = 1 LOOP\n"
249
+ " SELECT ID INTO index_id\n"
250
+ " FROM SYS_INDEXES\n"
251
+ " WHERE TABLE_ID = table_id\n"
252
+ " LOCK IN SHARE MODE;\n"
253
+ " IF (SQL % NOTFOUND) THEN\n"
256
+ " DELETE FROM SYS_FIELDS\n"
257
+ " WHERE INDEX_ID = index_id;\n"
258
+ " DELETE FROM SYS_INDEXES\n"
259
+ " WHERE ID = index_id\n"
260
+ " AND TABLE_ID = table_id;\n"
263
+ "DELETE FROM SYS_COLUMNS\n"
264
+ "WHERE TABLE_ID = table_id;\n"
265
+ "DELETE FROM SYS_TABLES\n"
266
+ "WHERE ID = table_id;\n"
270
+ trx_commit_for_mysql(trx);
272
+ trx_free_for_mysql(trx);
278
@@ -3836,7 +3933,7 @@
281
size = (((ib_int64_t)size_high) << 32) + (ib_int64_t)size_low;
282
-#ifndef UNIV_HOTBACKUP
284
if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
286
"InnoDB: Error: the size of single-table tablespace"
287
@@ -3977,7 +4074,7 @@
288
idea is to read as much good data as we can and jump over bad data.
289
@return 0 if ok, -1 if error even after the retries, 1 if at the end
294
fil_file_readdir_next_file(
295
/*=======================*/
296
@@ -4276,15 +4373,97 @@
297
"InnoDB: in InnoDB data dictionary"
298
" has tablespace id %lu,\n"
299
"InnoDB: but tablespace with that id"
300
- " or name does not exist. Have\n"
301
- "InnoDB: you deleted or moved .ibd files?\n"
302
- "InnoDB: This may also be a table created with"
303
- " CREATE TEMPORARY TABLE\n"
304
- "InnoDB: whose .ibd and .frm files"
305
- " MySQL automatically removed, but the\n"
306
- "InnoDB: table still exists in the"
307
- " InnoDB internal data dictionary.\n",
308
+ " or name does not exist. It will be removed from data dictionary.\n"
312
+ mutex_exit(&fil_system->mutex);
313
+ /* removing from data dictionary */
316
+ pars_info_t* info = NULL;
318
+ trx = trx_allocate_for_mysql();
320
+ trx->op_info = "removing invalid table from data dictionary";
322
+ info = pars_info_create();
324
+ pars_info_add_str_literal(info, "table_name", name);
327
+ "PROCEDURE DROP_TABLE_PROC () IS\n"
328
+ "sys_foreign_id CHAR;\n"
331
+ "foreign_id CHAR;\n"
334
+ "SELECT ID INTO table_id\n"
335
+ "FROM SYS_TABLES\n"
336
+ "WHERE NAME = :table_name\n"
337
+ "LOCK IN SHARE MODE;\n"
338
+ "IF (SQL % NOTFOUND) THEN\n"
342
+ "SELECT ID INTO sys_foreign_id\n"
343
+ "FROM SYS_TABLES\n"
344
+ "WHERE NAME = 'SYS_FOREIGN'\n"
345
+ "LOCK IN SHARE MODE;\n"
346
+ "IF (SQL % NOTFOUND) THEN\n"
349
+ "IF (:table_name = 'SYS_FOREIGN') THEN\n"
352
+ "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n"
355
+ "WHILE found = 1 LOOP\n"
356
+ " SELECT ID INTO foreign_id\n"
357
+ " FROM SYS_FOREIGN\n"
358
+ " WHERE FOR_NAME = :table_name\n"
359
+ " AND TO_BINARY(FOR_NAME)\n"
360
+ " = TO_BINARY(:table_name)\n"
361
+ " LOCK IN SHARE MODE;\n"
362
+ " IF (SQL % NOTFOUND) THEN\n"
365
+ " DELETE FROM SYS_FOREIGN_COLS\n"
366
+ " WHERE ID = foreign_id;\n"
367
+ " DELETE FROM SYS_FOREIGN\n"
368
+ " WHERE ID = foreign_id;\n"
372
+ "WHILE found = 1 LOOP\n"
373
+ " SELECT ID INTO index_id\n"
374
+ " FROM SYS_INDEXES\n"
375
+ " WHERE TABLE_ID = table_id\n"
376
+ " LOCK IN SHARE MODE;\n"
377
+ " IF (SQL % NOTFOUND) THEN\n"
380
+ " DELETE FROM SYS_FIELDS\n"
381
+ " WHERE INDEX_ID = index_id;\n"
382
+ " DELETE FROM SYS_INDEXES\n"
383
+ " WHERE ID = index_id\n"
384
+ " AND TABLE_ID = table_id;\n"
387
+ "DELETE FROM SYS_COLUMNS\n"
388
+ "WHERE TABLE_ID = table_id;\n"
389
+ "DELETE FROM SYS_TABLES\n"
390
+ "WHERE ID = table_id;\n"
394
+ trx_commit_for_mysql(trx);
396
+ trx_free_for_mysql(trx);
400
ut_print_timestamp(stderr);
401
fputs(" InnoDB: Error: table ", stderr);
402
@@ -4683,7 +4862,7 @@
403
off the LRU list if it is in the LRU list. The caller must hold the fil_sys
408
fil_node_prepare_for_io(
409
/*====================*/
410
fil_node_t* node, /*!< in: file node */
411
@@ -4703,10 +4882,13 @@
414
if (node->open == FALSE) {
416
/* File is closed: open it */
417
ut_a(node->n_pending == 0);
419
- fil_node_open_file(node, system, space);
420
+ err = fil_node_open_file(node, system, space);
425
if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
426
@@ -4719,6 +4901,8 @@
434
/********************************************************************//**
435
@@ -4920,6 +5104,16 @@
437
ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
439
+ if (space->size <= block_offset) {
442
+ mutex_exit(&fil_system->mutex);
443
+ fil_extend_space_to_desired_size(&actual_size, space->id,
444
+ ((block_offset + 1) / 64 + 1) * 64);
445
+ mutex_enter(&fil_system->mutex);
446
+ /* should retry? but it may safe for xtrabackup for now. */
449
node = UT_LIST_GET_FIRST(space->chain);
452
--- a/storage/innobase/handler/ha_innodb.cc 2011-03-15 07:53:56.000000000 -0700
453
+++ b/storage/innobase/handler/ha_innodb.cc 2011-03-15 07:59:54.000000000 -0700
455
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
456
NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
458
-static MYSQL_THDVAR_ULONG(flush_log_at_trx_commit, PLUGIN_VAR_OPCMDARG,
459
- "Set to 0 (write and flush once per second),"
460
- " 1 (write and flush at each commit)"
461
- " or 2 (write at commit, flush once per second).",
462
- NULL, NULL, 1, 0, 2, 0);
465
static handler *innobase_create_handler(handlerton *hton,
472
-/******************************************************************//**
474
-extern "C" UNIV_INTERN
476
-thd_flush_log_at_trx_commit(
477
-/*================================*/
480
- return(THDVAR((THD*) thd, flush_log_at_trx_commit));
483
/********************************************************************//**
484
Obtain the InnoDB transaction of a MySQL thread.
485
@return reference to transaction pointer */
486
@@ -11595,18 +11577,12 @@
487
innodb_file_format_max_validate,
488
innodb_file_format_max_update, "Antelope");
490
-/* Changed to the THDVAR */
491
-//static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
492
-// PLUGIN_VAR_OPCMDARG,
493
-// "Set to 0 (write and flush once per second),"
494
-// " 1 (write and flush at each commit)"
495
-// " or 2 (write at commit, flush once per second).",
496
-// NULL, NULL, 1, 0, 2, 0);
498
-static MYSQL_SYSVAR_BOOL(use_global_flush_log_at_trx_commit, srv_use_global_flush_log_at_trx_commit,
499
- PLUGIN_VAR_NOCMDARG,
500
- "Use global innodb_flush_log_at_trx_commit value. (default: ON).",
502
+static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
503
+ PLUGIN_VAR_OPCMDARG,
504
+ "Set to 0 (write and flush once per second),"
505
+ " 1 (write and flush at each commit)"
506
+ " or 2 (write at commit, flush once per second).",
507
+ NULL, NULL, 1, 0, 2, 0);
509
static MYSQL_SYSVAR_STR(flush_method, innobase_file_flush_method,
510
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
511
@@ -12073,7 +12049,6 @@
512
MYSQL_SYSVAR(file_format_check),
513
MYSQL_SYSVAR(file_format_max),
514
MYSQL_SYSVAR(flush_log_at_trx_commit),
515
- MYSQL_SYSVAR(use_global_flush_log_at_trx_commit),
516
MYSQL_SYSVAR(flush_method),
517
MYSQL_SYSVAR(force_recovery),
518
MYSQL_SYSVAR(locks_unsafe_for_binlog),
519
--- a/storage/innobase/ibuf/ibuf0ibuf.c 2011-03-15 07:56:04.000000000 -0700
520
+++ b/storage/innobase/ibuf/ibuf0ibuf.c 2011-03-15 07:56:47.000000000 -0700
521
@@ -1202,6 +1202,9 @@
522
ut_ad(!recv_no_ibuf_operations);
523
ut_ad(x_latch || mtr == NULL);
525
+ if (srv_fake_write)
528
if (ibuf_fixed_addr_page(space, zip_size, page_no)) {
531
@@ -2733,6 +2736,9 @@
535
+ if (srv_fake_write)
538
while (sum_pages < n_pages) {
539
n_bytes = ibuf_contract_ext(&n_pag2, sync);
541
--- a/storage/innobase/include/ha_prototypes.h 2011-03-15 07:56:04.000000000 -0700
542
+++ b/storage/innobase/include/ha_prototypes.h 2011-03-15 07:56:47.000000000 -0700
544
/*===================*/
545
void* thd, /*!< in: thread handle (THD*) */
546
ulint value); /*!< in: time waited for the lock */
547
-/******************************************************************//**
551
-thd_flush_log_at_trx_commit(
552
-/*================================*/
556
--- a/storage/innobase/include/srv0srv.h 2011-03-15 07:56:04.000000000 -0700
557
+++ b/storage/innobase/include/srv0srv.h 2011-03-15 07:56:47.000000000 -0700
559
extern ulint srv_n_log_files;
560
extern ulint srv_log_file_size;
561
extern ulint srv_log_buffer_size;
562
-//extern ulong srv_flush_log_at_trx_commit;
563
-extern char srv_use_global_flush_log_at_trx_commit;
564
+extern ulong srv_flush_log_at_trx_commit;
565
extern char srv_adaptive_flushing;
569
extern ulint srv_dict_size_limit;
571
extern ulint srv_lazy_drop_table;
573
+extern ibool srv_read_only;
574
+extern ibool srv_fake_write;
575
+extern ibool srv_apply_log_only;
576
/*-------------------------------------------*/
578
extern ulint srv_n_rows_inserted;
579
--- a/storage/innobase/include/srv0start.h 2011-03-15 07:56:04.000000000 -0700
580
+++ b/storage/innobase/include/srv0start.h 2011-03-15 07:56:47.000000000 -0700
582
/** Log sequence number immediately after startup */
583
extern ib_uint64_t srv_start_lsn;
585
+extern ib_uint64_t srv_oldest_lsn;
587
#ifdef HAVE_DARWIN_THREADS
588
/** TRUE if the F_FULLFSYNC option is available */
589
extern ibool srv_have_fullfsync;
590
--- a/storage/innobase/log/log0log.c 2011-03-15 07:56:04.000000000 -0700
591
+++ b/storage/innobase/log/log0log.c 2011-03-15 07:56:47.000000000 -0700
592
@@ -1154,7 +1154,7 @@
593
if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
594
&& srv_unix_file_flush_method != SRV_UNIX_ALL_O_DIRECT
595
&& srv_unix_file_flush_method != SRV_UNIX_NOSYNC
596
- && thd_flush_log_at_trx_commit(NULL) != 2) {
597
+ && srv_flush_log_at_trx_commit != 2) {
599
fil_flush(group->space_id);
601
@@ -1389,7 +1389,7 @@
602
#endif /* UNIV_DEBUG */
605
- if (recv_no_ibuf_operations) {
606
+ if (recv_no_ibuf_operations || srv_fake_write) {
607
/* Recovery is running and no operations on the log files are
608
allowed yet (the variable name .._no_ibuf_.. is misleading) */
610
@@ -3151,6 +3151,7 @@
611
for the 'very fast' shutdown, because the InnoDB layer may have
612
committed or prepared transactions and we don't want to lose them. */
614
+ if (!srv_apply_log_only) {
615
if (trx_n_mysql_transactions > 0
616
|| UT_LIST_GET_LEN(trx_sys->trx_list) > 0) {
618
@@ -3158,6 +3159,7 @@
624
if (srv_fast_shutdown == 2) {
625
/* In this fastest shutdown we do not flush the buffer pool:
626
--- a/storage/innobase/log/log0recv.c 2011-03-15 07:56:04.000000000 -0700
627
+++ b/storage/innobase/log/log0recv.c 2011-03-15 07:56:47.000000000 -0700
629
#include "trx0undo.h"
632
-#ifndef UNIV_HOTBACKUP
633
+//#ifndef UNIV_HOTBACKUP
634
# include "buf0rea.h"
635
# include "srv0srv.h"
636
# include "srv0start.h"
637
# include "trx0roll.h"
638
# include "row0merge.h"
639
# include "sync0sync.h"
640
-#else /* !UNIV_HOTBACKUP */
641
+//#else /* !UNIV_HOTBACKUP */
643
/** This is set to FALSE if the backup was originally taken with the
644
ibbackup --include regexp option: then we do not want to create tables in
645
directories which were not included */
646
UNIV_INTERN ibool recv_replay_file_ops = TRUE;
647
-#endif /* !UNIV_HOTBACKUP */
648
+//#endif /* !UNIV_HOTBACKUP */
650
/** Log records are stored in the hash table in chunks at most of this size;
651
this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
652
#define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
654
/** Read-ahead area in applying log records to file pages */
655
-#define RECV_READ_AHEAD_AREA 32
656
+#define RECV_READ_AHEAD_AREA 128
658
/** The recovery system */
659
UNIV_INTERN recv_sys_t* recv_sys = NULL;
661
/***********************************************************************//**
662
Checks the consistency of the checkpoint info
663
@return TRUE if ok */
667
recv_check_cp_is_consistent(
668
/*========================*/
670
/********************************************************//**
671
Looks for the maximum consistent checkpoint from the log groups.
672
@return error code or DB_SUCCESS */
676
recv_find_max_checkpoint(
677
/*=====================*/
679
InnoDB-3.23.52 where the checksum field contains the log block number.
680
@return TRUE if ok, or if the log block may be in the format of InnoDB
681
version predating 3.23.52 */
685
log_block_checksum_is_ok_or_old_format(
686
/*===================================*/
687
@@ -2380,7 +2380,7 @@
688
|| type == MLOG_FILE_RENAME
689
|| type == MLOG_FILE_DELETE) {
691
-#ifdef UNIV_HOTBACKUP
692
+//#ifdef UNIV_HOTBACKUP
693
if (recv_replay_file_ops) {
695
/* In ibbackup --apply-log, replay an .ibd file
696
@@ -2403,7 +2403,7 @@
702
/* In normal mysqld crash recovery we do not try to
703
replay file operations */
704
#ifdef UNIV_LOG_LSN_DEBUG
705
@@ -2820,8 +2820,11 @@
708
"InnoDB: Doing recovery: scanned up to"
709
- " log sequence number %llu\n",
710
- *group_scanned_lsn);
711
+ " log sequence number %llu (%lu %%)\n",
712
+ *group_scanned_lsn,
713
+ (ulong) (*group_scanned_lsn - srv_oldest_lsn)
714
+ / (8 * log_group_get_capacity(UT_LIST_GET_FIRST(log_sys->log_groups))/900)
719
@@ -2936,12 +2939,14 @@
721
if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
725
"InnoDB: Restoring possible"
726
" half-written data pages from"
728
"InnoDB: buffer...\n");
729
- trx_sys_doublewrite_init_or_restore_pages(TRUE);
731
+ trx_sys_doublewrite_init_or_restore_pages(FALSE);
735
@@ -3110,6 +3115,7 @@
736
recv_sys->recovered_lsn = checkpoint_lsn;
738
srv_start_lsn = checkpoint_lsn;
739
+ srv_oldest_lsn = checkpoint_lsn;
742
contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
743
@@ -3475,6 +3481,7 @@
744
that the data dictionary tables will be free of any locks.
745
The data dictionary latch should guarantee that there is at
746
most one data dictionary transaction active at a time. */
747
+ if (!srv_apply_log_only)
748
trx_rollback_or_clean_recovered(FALSE);
751
--- a/storage/innobase/os/os0file.c 2011-03-15 07:56:04.000000000 -0700
752
+++ b/storage/innobase/os/os0file.c 2011-03-15 07:56:47.000000000 -0700
757
-#define USE_FILE_LOCK
758
+//#define USE_FILE_LOCK
759
#if defined(UNIV_HOTBACKUP) || defined(__WIN__)
760
/* InnoDB Hot Backup does not lock the data files.
761
* On Windows, mandatory locking is used.
762
@@ -1428,7 +1428,7 @@
764
#ifdef UNIV_NON_BUFFERED_IO
765
# ifndef UNIV_HOTBACKUP
766
- if (type == OS_LOG_FILE && thd_flush_log_at_trx_commit(NULL) == 2) {
767
+ if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) {
768
/* Do not use unbuffered i/o to log files because
769
value 2 denotes that we do not flush the log at every
770
commit, but only once per second */
771
@@ -1444,7 +1444,7 @@
773
#ifdef UNIV_NON_BUFFERED_IO
774
# ifndef UNIV_HOTBACKUP
775
- if (type == OS_LOG_FILE && thd_flush_log_at_trx_commit(NULL) == 2) {
776
+ if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) {
777
/* Do not use unbuffered i/o to log files because
778
value 2 denotes that we do not flush the log at every
779
commit, but only once per second */
780
@@ -1460,8 +1460,9 @@
785
+ share_mode |= FILE_SHARE_WRITE; /* Why? */
786
file = CreateFile((LPCTSTR) name,
787
+ (srv_read_only && create_flag == OPEN_EXISTING) ? GENERIC_READ :
788
GENERIC_READ | GENERIC_WRITE, /* read and write
790
share_mode, /* File can be read also by other
791
@@ -1520,7 +1521,11 @@
792
if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW
793
|| create_mode == OS_FILE_OPEN_RETRY) {
795
- create_flag = O_RDWR;
796
+ if (srv_read_only) {
797
+ create_flag = O_RDONLY;
799
+ create_flag = O_RDWR;
801
} else if (create_mode == OS_FILE_CREATE) {
803
create_flag = O_RDWR | O_CREAT | O_EXCL;
804
@@ -2732,6 +2737,9 @@
805
ut_a((offset & 0xFFFFFFFFUL) == offset);
806
ut_a((n & 0xFFFFFFFFUL) == n);
808
+ if (srv_fake_write)
814
@@ -2856,6 +2864,9 @@
818
+ if (srv_fake_write)
821
ret = os_file_pwrite(file, buf, n, offset, offset_high);
823
if ((ulint)ret == n) {
824
--- a/storage/innobase/os/os0thread.c 2011-03-15 07:56:04.000000000 -0700
825
+++ b/storage/innobase/os/os0thread.c 2011-03-15 07:56:47.000000000 -0700
826
@@ -266,12 +266,17 @@
828
Sleep((DWORD) tm / 1000);
830
+ /* select() simetimes hang up from xtrabackup */
831
+ /* change to use usleep() for now */
836
t.tv_sec = tm / 1000000;
837
t.tv_usec = tm % 1000000;
839
select(0, NULL, NULL, NULL, &t);
844
--- a/storage/innobase/row/row0merge.c 2011-03-15 07:56:04.000000000 -0700
845
+++ b/storage/innobase/row/row0merge.c 2011-03-15 07:56:47.000000000 -0700
847
rec = rec_convert_dtuple_to_rec(*buf, index, tuple, n_ext);
848
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
850
- innobase_rec_to_mysql(dup->table, rec, index, offsets);
851
+ //innobase_rec_to_mysql(dup->table, rec, index, offsets);
852
+ fprintf(stderr, "InnoDB: Error: row_merge_dup_report() is called.\n");
857
@@ -1485,8 +1487,10 @@
860
(dict_index_is_unique(index) && !null_eq)) {
861
- innobase_rec_to_mysql(table, mrec0,
863
+ //innobase_rec_to_mysql(table, mrec0,
864
+ // index, offsets0);
865
+ fprintf(stderr, "InnoDB: Error: row_merge_blocks() is called.\n");
868
return(DB_DUPLICATE_KEY);
870
@@ -2613,7 +2617,9 @@
872
/* Reset the MySQL row buffer that is used when reporting
874
- innobase_rec_reset(table);
875
+ //innobase_rec_reset(table);
876
+ fprintf(stderr, "InnoDB: Error: row_merge_build_indexes() is called.\n");
879
/* Read clustered index of the table and create files for
880
secondary index entries for merge sort */
881
--- a/storage/innobase/srv/srv0srv.c 2011-03-15 07:56:04.000000000 -0700
882
+++ b/storage/innobase/srv/srv0srv.c 2011-03-15 07:56:47.000000000 -0700
884
UNIV_INTERN ulint srv_log_file_size = ULINT_MAX;
885
/* size in database pages */
886
UNIV_INTERN ulint srv_log_buffer_size = ULINT_MAX;
887
-//UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1;
888
-UNIV_INTERN char srv_use_global_flush_log_at_trx_commit = TRUE;
889
+UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1;
891
/* Try to flush dirty pages so as to avoid IO bursts at
894
UNIV_INTERN ulint srv_dict_size_limit = 0;
896
UNIV_INTERN ulint srv_lazy_drop_table = 0;
898
+UNIV_INTERN ibool srv_read_only = FALSE;
899
+UNIV_INTERN ibool srv_fake_write = FALSE;
900
+UNIV_INTERN ibool srv_apply_log_only = FALSE;
901
/*-------------------------------------------*/
902
UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
903
UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
904
@@ -1148,7 +1151,7 @@
907
/* Initialize some INFORMATION SCHEMA internal structures */
908
- trx_i_s_cache_init(trx_i_s_cache);
909
+ //trx_i_s_cache_init(trx_i_s_cache);
912
/*********************************************************************//**
913
@@ -1159,6 +1162,7 @@
916
os_fast_mutex_free(&srv_conc_mutex);
918
mem_free(srv_conc_slots);
919
srv_conc_slots = NULL;
921
@@ -1172,6 +1176,7 @@
922
srv_mysql_table = NULL;
924
trx_i_s_cache_free(trx_i_s_cache);
928
/*********************************************************************//**
929
@@ -1876,7 +1881,7 @@
932
/* Record the lock wait time for this thread */
933
- thd_set_lock_wait_time(trx->mysql_thd, diff_time);
934
+ //thd_set_lock_wait_time(trx->mysql_thd, diff_time);
937
if (trx->was_chosen_as_deadlock_victim) {
938
--- a/storage/innobase/srv/srv0start.c 2011-03-15 07:56:04.000000000 -0700
939
+++ b/storage/innobase/srv/srv0start.c 2011-03-15 07:56:47.000000000 -0700
941
/** Log sequence number at shutdown */
942
UNIV_INTERN ib_uint64_t srv_shutdown_lsn;
944
+UNIV_INTERN ib_uint64_t srv_oldest_lsn;
946
#ifdef HAVE_DARWIN_THREADS
947
# include <sys/utsname.h>
948
/** TRUE if the F_FULLFSYNC option is available */
950
/*********************************************************************//**
951
Creates or opens the log files and closes them.
952
@return DB_SUCCESS or error code */
956
open_or_create_log_file(
957
/*====================*/
959
/*********************************************************************//**
960
Creates or opens database data files and closes them.
961
@return DB_SUCCESS or error code */
965
open_or_create_data_files(
966
/*======================*/
967
@@ -1868,6 +1870,10 @@
968
are initialized in trx_sys_init_at_db_start(). */
970
recv_recovery_from_checkpoint_finish();
972
+ if (srv_apply_log_only)
973
+ goto skip_processes;
975
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
976
/* The following call is necessary for the insert
977
buffer to work with multiple tablespaces. We must
978
@@ -2042,6 +2048,17 @@
979
if (!srv_auto_extend_last_data_file
980
&& sum_of_data_file_sizes != tablespace_size_in_header) {
982
+ /* extend table space size aligning with header */
984
+ fil_extend_space_to_desired_size(&actual_size, 0, tablespace_size_in_header);
985
+ if (actual_size < tablespace_size_in_header) {
987
+"InnoDB: Warning: To extend tablespace size aligning with header seems to be failed.\n"
988
+"InnoDB: The acutual size %lu must be larger than %lu.\n",
989
+ (ulong) actual_size,
990
+ (ulong) tablespace_size_in_header);
993
ut_print_timestamp(stderr);
995
" InnoDB: Error: tablespace size"
996
@@ -2121,6 +2138,7 @@
1003
/* Check that os_fast_mutexes work as expected */
1004
@@ -2240,6 +2258,7 @@
1005
ibuf_update_max_tablespace_id();
1009
srv_file_per_table = srv_file_per_table_original_value;
1011
srv_was_started = TRUE;
1012
--- a/storage/innobase/trx/trx0purge.c 2011-03-15 07:56:04.000000000 -0700
1013
+++ b/storage/innobase/trx/trx0purge.c 2011-03-15 07:56:47.000000000 -0700
1014
@@ -1100,6 +1100,9 @@
1015
/* que_thr_t* thr2; */
1016
ulint old_pages_handled;
1018
+ if (srv_fake_write)
1021
mutex_enter(&(purge_sys->mutex));
1023
if (purge_sys->trx->n_active_thrs > 0) {
1024
--- a/storage/innobase/trx/trx0rseg.c 2011-03-15 07:56:04.000000000 -0700
1025
+++ b/storage/innobase/trx/trx0rseg.c 2011-03-15 07:56:47.000000000 -0700
1026
@@ -140,9 +140,11 @@
1028
mutex_free(&rseg->mutex);
1030
+ if (!srv_apply_log_only) {
1031
/* There can't be any active transactions. */
1032
ut_a(UT_LIST_GET_LEN(rseg->update_undo_list) == 0);
1033
ut_a(UT_LIST_GET_LEN(rseg->insert_undo_list) == 0);
1036
undo = UT_LIST_GET_FIRST(rseg->update_undo_cached);
1038
--- a/storage/innobase/trx/trx0sys.c 2011-03-15 07:56:04.000000000 -0700
1039
+++ b/storage/innobase/trx/trx0sys.c 2011-03-15 07:56:47.000000000 -0700
1040
@@ -1938,10 +1938,12 @@
1041
UT_LIST_REMOVE(view_list, trx_sys->view_list, prev_view);
1044
+ if (!srv_apply_log_only) {
1045
ut_a(UT_LIST_GET_LEN(trx_sys->trx_list) == 0);
1046
ut_a(UT_LIST_GET_LEN(trx_sys->rseg_list) == 0);
1047
ut_a(UT_LIST_GET_LEN(trx_sys->view_list) == 0);
1048
ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0);
1053
--- a/storage/innobase/trx/trx0trx.c 2011-03-15 07:56:04.000000000 -0700
1054
+++ b/storage/innobase/trx/trx0trx.c 2011-03-15 07:56:47.000000000 -0700
1058
if (srv_force_recovery == 0) {
1060
- trx->conc_state = TRX_PREPARED;
1061
+ /* xtrabackup should rollback it */
1062
+ trx->conc_state = TRX_ACTIVE;
1069
if (srv_force_recovery == 0) {
1071
+ /* xtrabackup should rollback it */
1079
trx->read_view = NULL;
1082
- ulint flush_log_at_trx_commit;
1084
mutex_exit(&kernel_mutex);
1086
@@ -934,12 +933,6 @@
1087
trx_undo_insert_cleanup(trx);
1090
- if (srv_use_global_flush_log_at_trx_commit) {
1091
- flush_log_at_trx_commit = thd_flush_log_at_trx_commit(NULL);
1093
- flush_log_at_trx_commit = thd_flush_log_at_trx_commit(trx->mysql_thd);
1096
/* NOTE that we could possibly make a group commit more
1097
efficient here: call os_thread_yield here to allow also other
1098
trxs to come to commit! */
1100
if (trx->flush_log_later) {
1101
/* Do nothing yet */
1102
trx->must_flush_log_later = TRUE;
1103
- } else if (flush_log_at_trx_commit == 0) {
1104
+ } else if (srv_flush_log_at_trx_commit == 0) {
1106
- } else if (flush_log_at_trx_commit == 1) {
1107
+ } else if (srv_flush_log_at_trx_commit == 1) {
1108
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
1109
/* Write the log but do not flush it to disk */
1113
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
1115
- } else if (flush_log_at_trx_commit == 2) {
1116
+ } else if (srv_flush_log_at_trx_commit == 2) {
1118
/* Write the log but do not flush it to disk */
1120
@@ -1665,23 +1658,16 @@
1121
trx_t* trx) /*!< in: trx handle */
1123
ib_uint64_t lsn = trx->commit_lsn;
1124
- ulint flush_log_at_trx_commit;
1128
trx->op_info = "flushing log";
1130
- if (srv_use_global_flush_log_at_trx_commit) {
1131
- flush_log_at_trx_commit = thd_flush_log_at_trx_commit(NULL);
1133
- flush_log_at_trx_commit = thd_flush_log_at_trx_commit(trx->mysql_thd);
1136
if (!trx->must_flush_log_later) {
1138
- } else if (flush_log_at_trx_commit == 0) {
1139
+ } else if (srv_flush_log_at_trx_commit == 0) {
1141
- } else if (flush_log_at_trx_commit == 1) {
1142
+ } else if (srv_flush_log_at_trx_commit == 1) {
1143
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
1144
/* Write the log but do not flush it to disk */
1146
@@ -1692,7 +1678,7 @@
1148
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
1150
- } else if (flush_log_at_trx_commit == 2) {
1151
+ } else if (srv_flush_log_at_trx_commit == 2) {
1153
/* Write the log but do not flush it to disk */
1155
@@ -1945,7 +1931,6 @@
1156
/*--------------------------------------*/
1159
- ulint flush_log_at_trx_commit;
1161
/* Depending on the my.cnf options, we may now write the log
1162
buffer to the log files, making the prepared state of the
1163
@@ -1966,15 +1951,9 @@
1165
mutex_exit(&kernel_mutex);
1167
- if (srv_use_global_flush_log_at_trx_commit) {
1168
- flush_log_at_trx_commit = thd_flush_log_at_trx_commit(NULL);
1170
- flush_log_at_trx_commit = thd_flush_log_at_trx_commit(trx->mysql_thd);
1173
- if (flush_log_at_trx_commit == 0) {
1174
+ if (srv_flush_log_at_trx_commit == 0) {
1176
- } else if (flush_log_at_trx_commit == 1) {
1177
+ } else if (srv_flush_log_at_trx_commit == 1) {
1178
if (srv_unix_file_flush_method == SRV_UNIX_NOSYNC) {
1179
/* Write the log but do not flush it to disk */
1181
@@ -1986,7 +1965,7 @@
1183
log_write_up_to(lsn, LOG_WAIT_ONE_GROUP, TRUE);
1185
- } else if (flush_log_at_trx_commit == 2) {
1186
+ } else if (srv_flush_log_at_trx_commit == 2) {
1188
/* Write the log but do not flush it to disk */