Merge lp:~akopytov/percona-xtrabackup/bug1079700-2.0 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 560
Proposed branch: lp:~akopytov/percona-xtrabackup/bug1079700-2.0
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 2342 lines (+854/-211)
11 files modified
patches/innodb51.patch (+116/-22)
patches/innodb51_builtin.patch (+123/-21)
patches/innodb55.patch (+118/-22)
patches/innodb56.patch (+102/-26)
patches/xtradb51.patch (+118/-25)
patches/xtradb55.patch (+106/-23)
src/xtrabackup.cc (+105/-39)
test/inc/common.sh (+19/-0)
test/t/ddl.sh (+37/-31)
test/testrun.sh (+3/-1)
utils/build.sh (+7/-1)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug1079700-2.0
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+162926@code.launchpad.net

Description of the change

Bug #1079700: Issues with renaming/rotating tables during the backup
              stage

The problem was in the way XtraBackup handled DDL on individual
tablespaces on the backup stage. It first created a list of tablespaces
to copy which is represented by fil_system, but when starting the actual
tablespace copy operation later, it opened tablespace files by name. If
a tablespace file could not be opened, XtraBackup assumed the tablespace
got removed after the fil_system list was created and ignored the
tablespaces. This naturally only worked for cases when the tablespace
got dropped. A renamed tablespace would be missing in the resulting
backup, and tablespace rotations resulted in a missing tablespace and a
duplicate copy of another tablespace participating in rotation.

The idea of the fix is to make sure that once a tablespace is added to
fil_system, the underlying file is copied to backup with the same name
and space ID, regardless of what operations have been performed on the
tablespace/file during the backup procedure.

The only way to achieve that is to reuse file handles created when
opening tablespaces and adding them to fil_system, i.e. never attempt to
access tablespaces by name and rely on the fact the an open file handle
will always point to the same inode, even if the file is unlink()ed or
rename()d along the way. In other words, exclude the case when we are
going to copy a tablespace, but the file does not exist already.

This requires changes to fil_load_single_table_tablespace() to not close
the file handle after adding a space/node to fil_system, but keep the
node open and assign the handle to node->handle. We could use
fil_node_open_file() for that, but that function creates another handle
and open the tablespace file by name, which would still leave some room
for a race condition during the time when fil_system is populated. This
also requires XtraBackup to close the node correctly basically to comply
with various invariants enforced by fil_validate() in debug builds. This
part is implemented in XtraBackup in xb_fil_node_close_file().

We also want to reuse file handles in fil_load_single_table_tablespace()
only at the backup stage. Historically, XtraBackup patches used
recv_recovery_on to detect whether we are currently in the 'backup' or
'recovery' mode. That doesn't always work reliably. For example, we may
initialize fil_system before we start recovery to apply an incremental
backup. So recovery is still not started, but we are not in the backup
mode either. To circumvent that, the patch introduces another global
variable srv_backup_mode which is set by XtraBackup only in
xtrabackup_backup_func(). This patch also changes remote tablespaces
support in innodb56.patch to use srv_backup_mode instead of
recv_recovery_on.

Another change necessitated by the patch is ignoring deleted tablespaces
on recovery, which has been implemented in XB patches to
recv_apply_hashed_log_recs(). After MLOG_FILE_DELETE is replayed on
recovery and the underlying file is deleted, possible updates to the
same tablespace done before deleting the tablespace are left in the redo
log. They will be ignored by the recovery code. This can never cause any
problems for server, because file creation/removal is done immediately,
so on recovery InnoDB detects missing tablespace files and does not the
corresponding log records to the hash table (see the first lines in
recv_add_to_hash_table). The situation is different with XtraBackup: the
underlying file will be present when recovery starts, but then get
deleted when MLOG_FILE_DELETE is replayed, i.e. after all log records
from the current batch have been added to the hash table. As a result,
log records corresponding to the deleted tablespace are ignore, but are
still left in the hash table, so recv_apply_hashed_log_recs() hangs
forever waiting for recv_sys->n_addrs to become zero. This was also
possible with XtraBackup before this fix, i.e. when a tablespace is
removed after it has been copied by XtraBackup. This fix just makes this
condition more likely to occur, as we always copy all tablespaces rather
than ignore those removed before the copy operation is tarted.

To fix the above case, we also check for deleted tablespaces in
recv_apply_hashed_log_recs(). Those corresponding to previously deleted
tablespaces are marked as processed and recv_sys->n_addrs is decremented
accordingly to not leave spurious unprocessed log records in the hash
table.

Finally, now that we reuse fil_system file handles again, bug #870119
needs another fix. I.e. the number of open file handles grows to the
number of tablespaces we want to copy, so we want to prevent InnoDB LRU
policies from kicking in and closing/reusing file handles. There are
multiple ways to achieve that. Patching InnoDB code to disable
fil_system LRU and file closing policies in InnoDB appeared to be too
risky. The easiest one is to set the allowed number of open InnoDB files
to some vary large value unconditionally (i.e. override
innodb_open_files with the maximum possible value, LONG_MAX). InnoDB
does not allocate any resource for each srv_max_n_open_files
increment. It's just the maximum possible LRU list length, so this
change does not incur any additional resource consumption.

This revision also extends bug722638.sh (since there's 95% overlap
between that one and the test case for this bug), and renames
bug722638.sh to ddl.sh to better reflect the contents. It also backports
record_db_state() / verify_db_state() from the 2.1 test suite, because
messing with individual table checksums and checksum_table looks rather
cumbersome with a higher number of tables in the test.

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.0-param/438/

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

    - The MLOG_FILE_DELETE bits need reconcilation and/or explanation
      on why the already existing hashed log rec handling in the
      patches for buf_page_read_low() is not enough. Maybe it's
      possible to tweak buf_page_read_low() patch instead of adding
      more patches to log0recv.c? Please see
      http://bugs.mysql.com/bug.php?id=43948 and
      https://bugs.launchpad.net/percona-xtrabackup/+bug/1121072
      which I have closed as Invalid due to this MP.

    - Will the following work:
      - XtraBackup creates a list of tablespaces;
      - CREATE TABLE foo is issued (optionally maybe even CREATE
        DATABASE first);
      - XtraBackup proceeds with backup;
      - Incremental backup is taken. Will it contain foo? It is
        possible that some of the foo writes will be captured in the
        full backup redo log backup.
      I guess this question boils down to "is fil_system snapshot
      taking atomic with the rest of backup state." CREATE TABLE
      specifically because other scenarios seem to be covered by this
      fix. I am not implying that I suspect it will or will not, I
      don't know and am curious.

    - This might be outside the scope of the current fix, but since
      you are backporting the mysqldump backup verifier, I am
      mentioning it here. If there's a bug/blueprint open for this,
      please point me there: mysqldump verification probably would miss
      secondary index tree corruptions, wouldn't it?

    - What are the s/AM_CONFIG_HEADER/AC_CONFIG_HEADERS bits for?
      Some bug fixed? If yes, is there a # ref?

    - Likewise for configure.cmake patch bits?

    - I recall seeing utils/build.sh patch elsewhere, yet there is
      only one unmerged revision in this MP. Is this intended?

review: Needs Information
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Hi Laurynas,

On Wed, 08 May 2013 14:48:26 -0000, Laurynas Biveinis wrote:
> Review: Needs Information
>
> - The MLOG_FILE_DELETE bits need reconcilation and/or explanation
> on why the already existing hashed log rec handling in the
> patches for buf_page_read_low() is not enough. Maybe it's
> possible to tweak buf_page_read_low() patch instead of adding
> more patches to log0recv.c? Please see
> http://bugs.mysql.com/bug.php?id=43948 and
> https://bugs.launchpad.net/percona-xtrabackup/+bug/1121072
> which I have closed as Invalid due to this MP.
>

The explanation is that you did not port the patch for bug #43948 to
innodb56.patch. Now that I have patched recv_apply_hashed_log_recs(),
the fix for bug 43948 in PS and innodb51.patch/innodb55.patch is redundant.

But since the goal is to get rid of all those patches, they will be
"reconciled" naturally.

> - Will the following work:
> - XtraBackup creates a list of tablespaces;
> - CREATE TABLE foo is issued (optionally maybe even CREATE
> DATABASE first);
> - XtraBackup proceeds with backup;
> - Incremental backup is taken. Will it contain foo? It is
> possible that some of the foo writes will be captured in the
> full backup redo log backup.
> I guess this question boils down to "is fil_system snapshot
> taking atomic with the rest of backup state." CREATE TABLE
> specifically because other scenarios seem to be covered by this
> fix. I am not implying that I suspect it will or will not, I
> don't know and am curious.
>

fil_op_log_parse_or_replay() does nothing if it has to replay
MLOG_FILE_CREATE and the tablespace already exists. So if the tablespace
makes it into fil_system at the backup stage, XtraBackup will ignore
MLOG_FILE_CREATE. Otherwise it will replay it. Not sure what difference
a subsequent incremental backup would make.

> - This might be outside the scope of the current fix, but since
> you are backporting the mysqldump backup verifier, I am
> mentioning it here. If there's a bug/blueprint open for this,
> please point me there: mysqldump verification probably would miss
> secondary index tree corruptions, wouldn't it?
>

Both mysqldump and CHECKSUM TABLE verification are identical for InnoDB.
CHECKSUM TABLE basically does "SELECT * FROM table" internally and
calculates checksums for all values in all rows. So corruption in
secondary index pages will also go unnoticed.

> - What are the s/AM_CONFIG_HEADER/AC_CONFIG_HEADERS bits for?
> Some bug fixed? If yes, is there a # ref?
>

It is a backport of the fix for bug #1164958 to older PS/MySQL 5.1 versions.

> - Likewise for configure.cmake patch bits?
>

Likewise, backports of the fix for
http://bugs.mysql.com/bug.php?id=65050 to older PS/MySQL 5.5 versions.

> - I recall seeing utils/build.sh patch elsewhere, yet there is
> only one unmerged revision in this MP. Is this intended?
>

That was for 2.1.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Hi Alexey -

> > - The MLOG_FILE_DELETE bits need reconcilation and/or explanation
> > http://bugs.mysql.com/bug.php?id=43948 and
>
> The explanation is that you did not port the patch for bug #43948 to
> innodb56.patch. Now that I have patched recv_apply_hashed_log_recs(),
> the fix for bug 43948 in PS and innodb51.patch/innodb55.patch is redundant.

Yes, I was wondering about other than innodb56.patch patches. The fact that I didn't patch innodb56.patch is/was https://bugs.launchpad.net/percona-xtrabackup/+bug/1121072. So if I understand correctly, now they will carry the both fixes and either fix may be reverted. And there is no point to spend effort to actually do this.

> > - This might be outside the scope of the current fix, but since
> > you are backporting the mysqldump backup verifier, I am
> > mentioning it here. If there's a bug/blueprint open for this,
> > please point me there: mysqldump verification probably would miss
> > secondary index tree corruptions, wouldn't it?
> >
>
> Both mysqldump and CHECKSUM TABLE verification are identical for InnoDB.
> CHECKSUM TABLE basically does "SELECT * FROM table" internally and
> calculates checksums for all values in all rows. So corruption in
> secondary index pages will also go unnoticed.

I didn't mention CHECKSUM TABLE anywhere in my comment for this very reason. So do we want to do something re. secondary index tree verifications?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'patches/innodb51.patch'
--- patches/innodb51.patch 2013-04-16 14:29:50 +0000
+++ patches/innodb51.patch 2013-05-08 05:16:27 +0000
@@ -444,7 +444,60 @@
444 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {444 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
445 fprintf(stderr,445 fprintf(stderr,
446 "InnoDB: Error: the size of single-table tablespace"446 "InnoDB: Error: the size of single-table tablespace"
447@@ -3425,7 +3530,7 @@447@@ -3414,7 +3519,51 @@
448
449 fil_node_create(filepath, 0, space_id, FALSE);
450 func_exit:
451- os_file_close(file);
452+ /* We reuse file handles on the backup stage in XtraBackup to avoid
453+ inconsistencies between the file name and the actual tablespace contents
454+ if a DDL occurs between a fil_load_single_table_tablespaces() call and
455+ the actual copy operation. */
456+ if (srv_backup_mode) {
457+
458+ fil_node_t* node;
459+ fil_space_t* space;
460+
461+ mutex_enter(&fil_system->mutex);
462+
463+ space = fil_space_get_by_id(space_id);
464+
465+ if (space) {
466+ node = UT_LIST_GET_LAST(space->chain);
467+
468+ /* The handle will be closed by xtrabackup in
469+ xtrabackup_copy_datafile(). We set node->open to TRUE to
470+ make sure no one calls fil_node_open_file()
471+ (i.e. attempts to reopen the tablespace by name) during
472+ the backup stage. */
473+
474+ node->open = TRUE;
475+ node->handle = file;
476+
477+ /* The following is copied from fil_node_open_file() to
478+ pass fil_system validity checks. We cannot use
479+ fil_node_open_file() directly, as that would re-open the
480+ file by name and create another file handle. */
481+
482+ fil_system->n_open++;
483+
484+ if (space->purpose == FIL_TABLESPACE &&
485+ space->id != 0) {
486+
487+ /* Put the node to the LRU list */
488+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
489+ }
490+ }
491+
492+ mutex_exit(&fil_system->mutex);
493+ } else {
494+
495+ os_file_close(file);
496+ }
497 ut_free(buf2);
498 mem_free(filepath);
499 }
500@@ -3425,7 +3574,7 @@
448 idea is to read as much good data as we can and jump over bad data.501 idea is to read as much good data as we can and jump over bad data.
449 @return 0 if ok, -1 if error even after the retries, 1 if at the end502 @return 0 if ok, -1 if error even after the retries, 1 if at the end
450 of the directory */503 of the directory */
@@ -453,7 +506,7 @@
453 int506 int
454 fil_file_readdir_next_file(507 fil_file_readdir_next_file(
455 /*=======================*/508 /*=======================*/
456@@ -3469,7 +3574,7 @@509@@ -3469,7 +3618,7 @@
457 @return DB_SUCCESS or error number */510 @return DB_SUCCESS or error number */
458 UNIV_INTERN511 UNIV_INTERN
459 ulint512 ulint
@@ -462,7 +515,7 @@
462 /*===================================*/515 /*===================================*/
463 {516 {
464 int ret;517 int ret;
465@@ -3525,7 +3630,9 @@518@@ -3525,7 +3674,9 @@
466 dbinfo.name);519 dbinfo.name);
467 srv_normalize_path_for_win(dbpath);520 srv_normalize_path_for_win(dbpath);
468 521
@@ -473,7 +526,7 @@
473 526
474 if (dbdir != NULL) {527 if (dbdir != NULL) {
475 /* printf("Opened dir %s\n", dbinfo.name); */528 /* printf("Opened dir %s\n", dbinfo.name); */
476@@ -3551,8 +3658,11 @@529@@ -3551,8 +3702,11 @@
477 ".ibd")) {530 ".ibd")) {
478 /* The name ends in .ibd; try opening531 /* The name ends in .ibd; try opening
479 the file */532 the file */
@@ -486,7 +539,7 @@
486 }539 }
487 next_file_item:540 next_file_item:
488 ret = fil_file_readdir_next_file(&err,541 ret = fil_file_readdir_next_file(&err,
489@@ -3724,15 +3834,97 @@542@@ -3724,15 +3878,97 @@
490 "InnoDB: in InnoDB data dictionary"543 "InnoDB: in InnoDB data dictionary"
491 " has tablespace id %lu,\n"544 " has tablespace id %lu,\n"
492 "InnoDB: but tablespace with that id"545 "InnoDB: but tablespace with that id"
@@ -592,7 +645,7 @@
592 } else {645 } else {
593 ut_print_timestamp(stderr);646 ut_print_timestamp(stderr);
594 fputs(" InnoDB: Error: table ", stderr);647 fputs(" InnoDB: Error: table ", stderr);
595@@ -4121,7 +4313,7 @@648@@ -4121,7 +4357,7 @@
596 off the LRU list if it is in the LRU list. The caller must hold the fil_sys649 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
597 mutex. */650 mutex. */
598 static651 static
@@ -601,7 +654,7 @@
601 fil_node_prepare_for_io(654 fil_node_prepare_for_io(
602 /*====================*/655 /*====================*/
603 fil_node_t* node, /*!< in: file node */656 fil_node_t* node, /*!< in: file node */
604@@ -4141,10 +4333,13 @@657@@ -4141,10 +4377,13 @@
605 }658 }
606 659
607 if (node->open == FALSE) {660 if (node->open == FALSE) {
@@ -616,7 +669,7 @@
616 }669 }
617 670
618 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE671 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
619@@ -4157,6 +4352,8 @@672@@ -4157,6 +4396,8 @@
620 }673 }
621 674
622 node->n_pending++;675 node->n_pending++;
@@ -625,7 +678,7 @@
625 }678 }
626 679
627 /********************************************************************//**680 /********************************************************************//**
628@@ -4292,7 +4489,9 @@681@@ -4292,7 +4533,9 @@
629 ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)682 ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
630 || !ibuf_bitmap_page(zip_size, block_offset)683 || !ibuf_bitmap_page(zip_size, block_offset)
631 || sync || is_log);684 || sync || is_log);
@@ -636,7 +689,7 @@
636 || ibuf_page(space_id, zip_size, block_offset, NULL));689 || ibuf_page(space_id, zip_size, block_offset, NULL));
637 # endif /* UNIV_LOG_DEBUG */690 # endif /* UNIV_LOG_DEBUG */
638 if (sync) {691 if (sync) {
639@@ -4341,6 +4540,16 @@692@@ -4341,6 +4584,16 @@
640 693
641 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));694 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
642 695
@@ -710,7 +763,7 @@
710 763
711--- a/storage/innodb_plugin/include/srv0srv.h764--- a/storage/innodb_plugin/include/srv0srv.h
712+++ b/storage/innodb_plugin/include/srv0srv.h765+++ b/storage/innodb_plugin/include/srv0srv.h
713@@ -202,6 +202,10 @@766@@ -202,6 +202,11 @@
714 extern ulong srv_max_purge_lag;767 extern ulong srv_max_purge_lag;
715 768
716 extern ulong srv_replication_delay;769 extern ulong srv_replication_delay;
@@ -718,6 +771,7 @@
718+extern ibool srv_read_only;771+extern ibool srv_read_only;
719+extern ibool srv_fake_write;772+extern ibool srv_fake_write;
720+extern ibool srv_apply_log_only;773+extern ibool srv_apply_log_only;
774+extern ibool srv_backup_mode;
721 /*-------------------------------------------*/775 /*-------------------------------------------*/
722 776
723 extern ulint srv_n_rows_inserted;777 extern ulint srv_n_rows_inserted;
@@ -912,7 +966,35 @@
912 || (recv_addr->state == RECV_BEING_PROCESSED)966 || (recv_addr->state == RECV_BEING_PROCESSED)
913 || (recv_addr->state == RECV_PROCESSED)) {967 || (recv_addr->state == RECV_PROCESSED)) {
914 968
915@@ -2297,7 +2298,7 @@969@@ -1762,6 +1763,18 @@
970 ulint zip_size = fil_space_get_zip_size(space);
971 ulint page_no = recv_addr->page_no;
972
973+ /* By now we have replayed all DDL log records from the
974+ current batch. Check if the space ID is still valid in
975+ the entry being processed, and ignore it if it is not.*/
976+ if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
977+
978+ ut_a(recv_sys->n_addrs);
979+
980+ recv_addr->state = RECV_PROCESSED;
981+ recv_sys->n_addrs--;
982+
983+ goto next;
984+ }
985 if (recv_addr->state == RECV_NOT_PROCESSED) {
986 if (!has_printed) {
987 ut_print_timestamp(stderr);
988@@ -1795,7 +1808,7 @@
989
990 mutex_enter(&(recv_sys->mutex));
991 }
992-
993+next:
994 recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
995 }
996
997@@ -2297,7 +2310,7 @@
916 || type == MLOG_FILE_RENAME998 || type == MLOG_FILE_RENAME
917 || type == MLOG_FILE_DELETE) {999 || type == MLOG_FILE_DELETE) {
918 ut_a(space);1000 ut_a(space);
@@ -921,7 +1003,7 @@
921 if (recv_replay_file_ops) {1003 if (recv_replay_file_ops) {
922 1004
923 /* In ibbackup --apply-log, replay an .ibd file1005 /* In ibbackup --apply-log, replay an .ibd file
924@@ -2320,7 +2321,7 @@1006@@ -2320,7 +2333,7 @@
925 ut_error;1007 ut_error;
926 }1008 }
927 }1009 }
@@ -930,7 +1012,7 @@
930 /* In normal mysqld crash recovery we do not try to1012 /* In normal mysqld crash recovery we do not try to
931 replay file operations */1013 replay file operations */
932 #ifdef UNIV_LOG_LSN_DEBUG1014 #ifdef UNIV_LOG_LSN_DEBUG
933@@ -2737,8 +2738,11 @@1015@@ -2737,8 +2750,11 @@
934 1016
935 fprintf(stderr,1017 fprintf(stderr,
936 "InnoDB: Doing recovery: scanned up to"1018 "InnoDB: Doing recovery: scanned up to"
@@ -944,7 +1026,7 @@
944 }1026 }
945 }1027 }
946 1028
947@@ -2841,7 +2845,7 @@1029@@ -2841,7 +2857,7 @@
948 "InnoDB: Reading tablespace information"1030 "InnoDB: Reading tablespace information"
949 " from the .ibd files...\n");1031 " from the .ibd files...\n");
950 1032
@@ -953,7 +1035,7 @@
953 1035
954 /* If we are using the doublewrite method, we will1036 /* If we are using the doublewrite method, we will
955 check if there are half-written pages in data files,1037 check if there are half-written pages in data files,
956@@ -2850,12 +2854,14 @@1038@@ -2850,12 +2866,14 @@
957 1039
958 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {1040 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
959 1041
@@ -969,7 +1051,7 @@
969 }1051 }
970 }1052 }
971 1053
972@@ -3005,6 +3011,7 @@1054@@ -3005,6 +3023,7 @@
973 recv_sys->recovered_lsn = checkpoint_lsn;1055 recv_sys->recovered_lsn = checkpoint_lsn;
974 1056
975 srv_start_lsn = checkpoint_lsn;1057 srv_start_lsn = checkpoint_lsn;
@@ -977,7 +1059,7 @@
977 }1059 }
978 1060
979 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,1061 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
980@@ -3286,6 +3293,7 @@1062@@ -3286,6 +3305,7 @@
981 that the data dictionary tables will be free of any locks.1063 that the data dictionary tables will be free of any locks.
982 The data dictionary latch should guarantee that there is at1064 The data dictionary latch should guarantee that there is at
983 most one data dictionary transaction active at a time. */1065 most one data dictionary transaction active at a time. */
@@ -1102,17 +1184,18 @@
1102 secondary index entries for merge sort */1184 secondary index entries for merge sort */
1103--- a/storage/innodb_plugin/srv/srv0srv.c1185--- a/storage/innodb_plugin/srv/srv0srv.c
1104+++ b/storage/innodb_plugin/srv/srv0srv.c1186+++ b/storage/innodb_plugin/srv/srv0srv.c
1105@@ -374,6 +374,9 @@1187@@ -374,6 +374,10 @@
1106 1188
1107 UNIV_INTERN ulong srv_replication_delay = 0;1189 UNIV_INTERN ulong srv_replication_delay = 0;
1108 1190
1109+UNIV_INTERN ibool srv_read_only = FALSE;1191+UNIV_INTERN ibool srv_read_only = FALSE;
1110+UNIV_INTERN ibool srv_fake_write = FALSE;1192+UNIV_INTERN ibool srv_fake_write = FALSE;
1111+UNIV_INTERN ibool srv_apply_log_only = FALSE;1193+UNIV_INTERN ibool srv_apply_log_only = FALSE;
1194+UNIV_INTERN ibool srv_backup_mode = FALSE;
1112 /*-------------------------------------------*/1195 /*-------------------------------------------*/
1113 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;1196 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
1114 UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;1197 UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
1115@@ -1002,7 +1005,7 @@1198@@ -1002,7 +1006,7 @@
1116 }1199 }
1117 1200
1118 /* Initialize some INFORMATION SCHEMA internal structures */1201 /* Initialize some INFORMATION SCHEMA internal structures */
@@ -1121,7 +1204,7 @@
1121 }1204 }
1122 1205
1123 /*********************************************************************//**1206 /*********************************************************************//**
1124@@ -1013,6 +1016,7 @@1207@@ -1013,6 +1017,7 @@
1125 /*==========*/1208 /*==========*/
1126 {1209 {
1127 os_fast_mutex_free(&srv_conc_mutex);1210 os_fast_mutex_free(&srv_conc_mutex);
@@ -1129,7 +1212,7 @@
1129 mem_free(srv_conc_slots);1212 mem_free(srv_conc_slots);
1130 srv_conc_slots = NULL;1213 srv_conc_slots = NULL;
1131 1214
1132@@ -1026,6 +1030,7 @@1215@@ -1026,6 +1031,7 @@
1133 srv_mysql_table = NULL;1216 srv_mysql_table = NULL;
1134 1217
1135 trx_i_s_cache_free(trx_i_s_cache);1218 trx_i_s_cache_free(trx_i_s_cache);
@@ -1347,3 +1430,14 @@
1347 1430
1348 UNIV_MEM_FREE(buf, n);1431 UNIV_MEM_FREE(buf, n);
1349 }1432 }
1433--- a/configure.in
1434+++ b/configure.in
1435@@ -22,7 +22,7 @@
1436 AM_INIT_AUTOMAKE([1.9 tar-ustar])
1437 AC_PROG_LIBTOOL
1438
1439-AM_CONFIG_HEADER([include/config.h])
1440+AC_CONFIG_HEADERS([include/config.h])
1441
1442 # Request support for automake silent-rules if available.
1443 # Default to verbose output. One can use the configure-time
13501444
=== modified file 'patches/innodb51_builtin.patch'
--- patches/innodb51_builtin.patch 2013-04-16 14:29:50 +0000
+++ patches/innodb51_builtin.patch 2013-05-08 05:16:27 +0000
@@ -231,6 +231,15 @@
231 }231 }
232 232
233 /**************************************************************************233 /**************************************************************************
234@@ -1227,7 +1247,7 @@
235 return(TRUE);
236 }
237
238-#ifdef UNIV_HOTBACKUP
239+#if 1
240 /***********************************************************************
241 Returns the tablespace object for a given id, or NULL if not found from the
242 tablespace memory cache. */
234@@ -1288,7 +1308,12 @@243@@ -1288,7 +1308,12 @@
235 the file yet; the following calls will open it and update the244 the file yet; the following calls will open it and update the
236 size fields */245 size fields */
@@ -410,7 +419,60 @@
410 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {419 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
411 fprintf(stderr,420 fprintf(stderr,
412 "InnoDB: Error: the size of single-table tablespace"421 "InnoDB: Error: the size of single-table tablespace"
413@@ -3152,7 +3256,7 @@422@@ -3143,7 +3247,51 @@
423
424 fil_node_create(filepath, 0, space_id, FALSE);
425 func_exit:
426- os_file_close(file);
427+ /* We reuse file handles on the backup stage in XtraBackup to avoid
428+ inconsistencies between the file name and the actual tablespace contents
429+ if a DDL occurs between a fil_load_single_table_tablespaces() call and
430+ the actual copy operation. */
431+ if (srv_backup_mode) {
432+
433+ fil_node_t* node;
434+ fil_space_t* space;
435+
436+ mutex_enter(&fil_system->mutex);
437+
438+ space = fil_get_space_for_id_low(space_id);
439+
440+ if (space) {
441+ node = UT_LIST_GET_LAST(space->chain);
442+
443+ /* The handle will be closed by xtrabackup in
444+ xtrabackup_copy_datafile(). We set node->open to TRUE to
445+ make sure no one calls fil_node_open_file()
446+ (i.e. attempts to reopen the tablespace by name) during
447+ the backup stage. */
448+
449+ node->open = TRUE;
450+ node->handle = file;
451+
452+ /* The following is copied from fil_node_open_file() to
453+ pass fil_system validity checks. We cannot use
454+ fil_node_open_file() directly, as that would re-open the
455+ file by name and create another file handle. */
456+
457+ fil_system->n_open++;
458+
459+ if (space->purpose == FIL_TABLESPACE &&
460+ space->id != 0) {
461+
462+ /* Put the node to the LRU list */
463+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
464+ }
465+ }
466+
467+ mutex_exit(&fil_system->mutex);
468+ } else {
469+
470+ os_file_close(file);
471+ }
472 ut_free(buf2);
473 mem_free(filepath);
474 }
475@@ -3152,7 +3300,7 @@
414 A fault-tolerant function that tries to read the next file name in the476 A fault-tolerant function that tries to read the next file name in the
415 directory. We retry 100 times if os_file_readdir_next_file() returns -1. The477 directory. We retry 100 times if os_file_readdir_next_file() returns -1. The
416 idea is to read as much good data as we can and jump over bad data. */478 idea is to read as much good data as we can and jump over bad data. */
@@ -419,7 +481,7 @@
419 int481 int
420 fil_file_readdir_next_file(482 fil_file_readdir_next_file(
421 /*=======================*/483 /*=======================*/
422@@ -3197,7 +3301,7 @@484@@ -3197,7 +3345,7 @@
423 space id is != 0. */485 space id is != 0. */
424 486
425 ulint487 ulint
@@ -428,7 +490,7 @@
428 /*===================================*/490 /*===================================*/
429 /* out: DB_SUCCESS or error number */491 /* out: DB_SUCCESS or error number */
430 {492 {
431@@ -3254,7 +3358,9 @@493@@ -3254,7 +3402,9 @@
432 dbinfo.name);494 dbinfo.name);
433 srv_normalize_path_for_win(dbpath);495 srv_normalize_path_for_win(dbpath);
434 496
@@ -439,7 +501,7 @@
439 501
440 if (dbdir != NULL) {502 if (dbdir != NULL) {
441 /* printf("Opened dir %s\n", dbinfo.name); */503 /* printf("Opened dir %s\n", dbinfo.name); */
442@@ -3280,8 +3386,11 @@504@@ -3280,8 +3430,11 @@
443 ".ibd")) {505 ".ibd")) {
444 /* The name ends in .ibd; try opening506 /* The name ends in .ibd; try opening
445 the file */507 the file */
@@ -452,7 +514,7 @@
452 }514 }
453 next_file_item:515 next_file_item:
454 ret = fil_file_readdir_next_file(&err,516 ret = fil_file_readdir_next_file(&err,
455@@ -3500,15 +3609,100 @@517@@ -3500,15 +3653,100 @@
456 "InnoDB: in InnoDB data dictionary"518 "InnoDB: in InnoDB data dictionary"
457 " has tablespace id %lu,\n"519 " has tablespace id %lu,\n"
458 "InnoDB: but tablespace with that id"520 "InnoDB: but tablespace with that id"
@@ -561,7 +623,7 @@
561 } else {623 } else {
562 ut_print_timestamp(stderr);624 ut_print_timestamp(stderr);
563 fputs(" InnoDB: Error: table ", stderr);625 fputs(" InnoDB: Error: table ", stderr);
564@@ -3901,7 +4095,7 @@626@@ -3901,7 +4139,7 @@
565 off the LRU list if it is in the LRU list. The caller must hold the fil_sys627 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
566 mutex. */628 mutex. */
567 static629 static
@@ -570,7 +632,7 @@
570 fil_node_prepare_for_io(632 fil_node_prepare_for_io(
571 /*====================*/633 /*====================*/
572 fil_node_t* node, /* in: file node */634 fil_node_t* node, /* in: file node */
573@@ -3921,10 +4115,14 @@635@@ -3921,10 +4159,14 @@
574 }636 }
575 637
576 if (node->open == FALSE) {638 if (node->open == FALSE) {
@@ -586,7 +648,7 @@
586 }648 }
587 649
588 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE650 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
589@@ -3937,6 +4135,8 @@651@@ -3937,6 +4179,8 @@
590 }652 }
591 653
592 node->n_pending++;654 node->n_pending++;
@@ -595,7 +657,7 @@
595 }657 }
596 658
597 /************************************************************************659 /************************************************************************
598@@ -4067,7 +4267,9 @@660@@ -4067,7 +4311,9 @@
599 ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)661 ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
600 || !ibuf_bitmap_page(block_offset) || sync || is_log);662 || !ibuf_bitmap_page(block_offset) || sync || is_log);
601 #ifdef UNIV_SYNC_DEBUG663 #ifdef UNIV_SYNC_DEBUG
@@ -606,7 +668,7 @@
606 || ibuf_page(space_id, block_offset));668 || ibuf_page(space_id, block_offset));
607 #endif669 #endif
608 #endif670 #endif
609@@ -4112,6 +4314,16 @@671@@ -4112,6 +4358,16 @@
610 672
611 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));673 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
612 674
@@ -746,7 +808,7 @@
746 extern ulint srv_pool_size;808 extern ulint srv_pool_size;
747 extern ulint srv_awe_window_size;809 extern ulint srv_awe_window_size;
748 extern ulint srv_mem_pool_size;810 extern ulint srv_mem_pool_size;
749@@ -138,6 +141,10 @@811@@ -138,6 +141,11 @@
750 extern ulong srv_max_purge_lag;812 extern ulong srv_max_purge_lag;
751 extern ibool srv_use_awe;813 extern ibool srv_use_awe;
752 extern ibool srv_use_adaptive_hash_indexes;814 extern ibool srv_use_adaptive_hash_indexes;
@@ -754,6 +816,7 @@
754+extern ibool srv_read_only;816+extern ibool srv_read_only;
755+extern ibool srv_fake_write;817+extern ibool srv_fake_write;
756+extern ibool srv_apply_log_only;818+extern ibool srv_apply_log_only;
819+extern ibool srv_backup_mode;
757 /*-------------------------------------------*/820 /*-------------------------------------------*/
758 821
759 extern ulint srv_n_rows_inserted;822 extern ulint srv_n_rows_inserted;
@@ -956,7 +1019,34 @@
956 || (recv_addr->state == RECV_BEING_PROCESSED)1019 || (recv_addr->state == RECV_BEING_PROCESSED)
957 || (recv_addr->state == RECV_PROCESSED)) {1020 || (recv_addr->state == RECV_PROCESSED)) {
958 1021
959@@ -1926,7 +1927,7 @@1022@@ -1429,6 +1430,18 @@
1023 space = recv_addr->space;
1024 page_no = recv_addr->page_no;
1025
1026+ /* By now we have replayed all DDL log records from the
1027+ current batch. Check if the space ID is still valid in
1028+ the entry being processed, and ignore it if it is not.*/
1029+ if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
1030+
1031+ ut_a(recv_sys->n_addrs);
1032+
1033+ recv_addr->state = RECV_PROCESSED;
1034+ recv_sys->n_addrs--;
1035+
1036+ goto next;
1037+ }
1038 if (recv_addr->state == RECV_NOT_PROCESSED) {
1039 if (!has_printed) {
1040 ut_print_timestamp(stderr);
1041@@ -1463,6 +1476,7 @@
1042 mutex_enter(&(recv_sys->mutex));
1043 }
1044
1045+next:
1046 recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
1047 }
1048
1049@@ -1926,7 +1940,7 @@
960 } else if (store_to_hash && (type == MLOG_FILE_CREATE1050 } else if (store_to_hash && (type == MLOG_FILE_CREATE
961 || type == MLOG_FILE_RENAME1051 || type == MLOG_FILE_RENAME
962 || type == MLOG_FILE_DELETE)) {1052 || type == MLOG_FILE_DELETE)) {
@@ -965,7 +1055,7 @@
965 if (recv_replay_file_ops) {1055 if (recv_replay_file_ops) {
966 1056
967 /* In ibbackup --apply-log, replay an .ibd file1057 /* In ibbackup --apply-log, replay an .ibd file
968@@ -1949,7 +1950,7 @@1058@@ -1949,7 +1963,7 @@
969 ut_a(0);1059 ut_a(0);
970 }1060 }
971 }1061 }
@@ -974,7 +1064,7 @@
974 /* In normal mysqld crash recovery we do not try to1064 /* In normal mysqld crash recovery we do not try to
975 replay file operations */1065 replay file operations */
976 } else if (store_to_hash) {1066 } else if (store_to_hash) {
977@@ -2360,9 +2361,12 @@1067@@ -2360,9 +2374,12 @@
978 1068
979 fprintf(stderr,1069 fprintf(stderr,
980 "InnoDB: Doing recovery: scanned up to"1070 "InnoDB: Doing recovery: scanned up to"
@@ -989,7 +1079,7 @@
989 }1079 }
990 }1080 }
991 1081
992@@ -2462,7 +2466,7 @@1082@@ -2462,7 +2479,7 @@
993 "InnoDB: Reading tablespace information"1083 "InnoDB: Reading tablespace information"
994 " from the .ibd files...\n");1084 " from the .ibd files...\n");
995 1085
@@ -998,7 +1088,7 @@
998 1088
999 /* If we are using the doublewrite method, we will1089 /* If we are using the doublewrite method, we will
1000 check if there are half-written pages in data files,1090 check if there are half-written pages in data files,
1001@@ -2471,12 +2475,14 @@1091@@ -2471,12 +2488,14 @@
1002 1092
1003 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {1093 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
1004 1094
@@ -1014,7 +1104,7 @@
1014 }1104 }
1015 }1105 }
1016 1106
1017@@ -2611,6 +2617,7 @@1107@@ -2611,6 +2630,7 @@
1018 recv_sys->recovered_lsn = checkpoint_lsn;1108 recv_sys->recovered_lsn = checkpoint_lsn;
1019 1109
1020 srv_start_lsn = checkpoint_lsn;1110 srv_start_lsn = checkpoint_lsn;
@@ -1022,7 +1112,7 @@
1022 }1112 }
1023 1113
1024 contiguous_lsn = ut_dulint_align_down(recv_sys->scanned_lsn,1114 contiguous_lsn = ut_dulint_align_down(recv_sys->scanned_lsn,
1025@@ -2910,6 +2917,7 @@1115@@ -2910,6 +2930,7 @@
1026 /* Switch latching order checks on in sync0sync.c */1116 /* Switch latching order checks on in sync0sync.c */
1027 sync_order_checks_on = TRUE;1117 sync_order_checks_on = TRUE;
1028 #endif1118 #endif
@@ -1030,7 +1120,7 @@
1030 if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) {1120 if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) {
1031 /* Rollback the uncommitted transactions which have no user1121 /* Rollback the uncommitted transactions which have no user
1032 session */1122 session */
1033@@ -2917,6 +2925,7 @@1123@@ -2917,6 +2938,7 @@
1034 os_thread_create(trx_rollback_or_clean_all_without_sess,1124 os_thread_create(trx_rollback_or_clean_all_without_sess,
1035 (void *)&i, NULL);1125 (void *)&i, NULL);
1036 }1126 }
@@ -1346,17 +1436,18 @@
1346 ulint srv_pool_size = ULINT_MAX; /* size in pages; MySQL inits1436 ulint srv_pool_size = ULINT_MAX; /* size in pages; MySQL inits
1347 this to size in kilobytes but1437 this to size in kilobytes but
1348 we normalize this to pages in1438 we normalize this to pages in
1349@@ -363,6 +367,9 @@1439@@ -363,6 +367,10 @@
1350 ibool srv_use_awe = FALSE;1440 ibool srv_use_awe = FALSE;
1351 ibool srv_use_adaptive_hash_indexes = TRUE;1441 ibool srv_use_adaptive_hash_indexes = TRUE;
1352 1442
1353+ibool srv_read_only = FALSE;1443+ibool srv_read_only = FALSE;
1354+ibool srv_fake_write = FALSE;1444+ibool srv_fake_write = FALSE;
1355+ibool srv_apply_log_only = FALSE;1445+ibool srv_apply_log_only = FALSE;
1446+ibool srv_backup_mode = FALSE;
1356 /*-------------------------------------------*/1447 /*-------------------------------------------*/
1357 ulong srv_n_spin_wait_rounds = 20;1448 ulong srv_n_spin_wait_rounds = 20;
1358 ulong srv_n_free_tickets_to_enter = 500;1449 ulong srv_n_free_tickets_to_enter = 500;
1359@@ -985,6 +992,7 @@1450@@ -985,6 +993,7 @@
1360 srv_general_init(void)1451 srv_general_init(void)
1361 /*==================*/1452 /*==================*/
1362 {1453 {
@@ -1605,3 +1696,14 @@
1605 1696
1606 if (rec_len != UNIV_SQL_NULL) {1697 if (rec_len != UNIV_SQL_NULL) {
1607 n_not_null[i]++;1698 n_not_null[i]++;
1699--- a/configure.in
1700+++ b/configure.in
1701@@ -22,7 +22,7 @@
1702 AM_INIT_AUTOMAKE([1.9 tar-ustar])
1703 AC_PROG_LIBTOOL
1704
1705-AM_CONFIG_HEADER([include/config.h])
1706+AC_CONFIG_HEADERS([include/config.h])
1707
1708 # Request support for automake silent-rules if available.
1709 # Default to verbose output. One can use the configure-time
16081710
=== modified file 'patches/innodb55.patch'
--- patches/innodb55.patch 2013-04-16 14:29:50 +0000
+++ patches/innodb55.patch 2013-05-08 05:16:27 +0000
@@ -433,7 +433,60 @@
433 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {433 if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
434 fprintf(stderr,434 fprintf(stderr,
435 "InnoDB: Error: the size of single-table tablespace"435 "InnoDB: Error: the size of single-table tablespace"
436@@ -3476,7 +3581,7 @@436@@ -3465,7 +3570,51 @@
437
438 fil_node_create(filepath, 0, space_id, FALSE);
439 func_exit:
440- os_file_close(file);
441+ /* We reuse file handles on the backup stage in XtraBackup to avoid
442+ inconsistencies between the file name and the actual tablespace contents
443+ if a DDL occurs between a fil_load_single_table_tablespaces() call and
444+ the actual copy operation. */
445+ if (srv_backup_mode) {
446+
447+ fil_node_t* node;
448+ fil_space_t* space;
449+
450+ mutex_enter(&fil_system->mutex);
451+
452+ space = fil_space_get_by_id(space_id);
453+
454+ if (space) {
455+ node = UT_LIST_GET_LAST(space->chain);
456+
457+ /* The handle will be closed by xtrabackup in
458+ xtrabackup_copy_datafile(). We set node->open to TRUE to
459+ make sure no one calls fil_node_open_file()
460+ (i.e. attempts to reopen the tablespace by name) during
461+ the backup stage. */
462+
463+ node->open = TRUE;
464+ node->handle = file;
465+
466+ /* The following is copied from fil_node_open_file() to
467+ pass fil_system validity checks. We cannot use
468+ fil_node_open_file() directly, as that would re-open the
469+ file by name and create another file handle. */
470+
471+ fil_system->n_open++;
472+
473+ if (space->purpose == FIL_TABLESPACE &&
474+ space->id != 0) {
475+
476+ /* Put the node to the LRU list */
477+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
478+ }
479+ }
480+
481+ mutex_exit(&fil_system->mutex);
482+ } else {
483+
484+ os_file_close(file);
485+ }
486 ut_free(buf2);
487 mem_free(filepath);
488 }
489@@ -3476,7 +3625,7 @@
437 idea is to read as much good data as we can and jump over bad data.490 idea is to read as much good data as we can and jump over bad data.
438 @return 0 if ok, -1 if error even after the retries, 1 if at the end491 @return 0 if ok, -1 if error even after the retries, 1 if at the end
439 of the directory */492 of the directory */
@@ -442,7 +495,7 @@
442 int495 int
443 fil_file_readdir_next_file(496 fil_file_readdir_next_file(
444 /*=======================*/497 /*=======================*/
445@@ -3520,7 +3625,7 @@498@@ -3520,7 +3669,7 @@
446 @return DB_SUCCESS or error number */499 @return DB_SUCCESS or error number */
447 UNIV_INTERN500 UNIV_INTERN
448 ulint501 ulint
@@ -451,7 +504,7 @@
451 /*===================================*/504 /*===================================*/
452 {505 {
453 int ret;506 int ret;
454@@ -3576,7 +3681,9 @@507@@ -3576,7 +3725,9 @@
455 dbinfo.name);508 dbinfo.name);
456 srv_normalize_path_for_win(dbpath);509 srv_normalize_path_for_win(dbpath);
457 510
@@ -462,7 +515,7 @@
462 515
463 if (dbdir != NULL) {516 if (dbdir != NULL) {
464 /* printf("Opened dir %s\n", dbinfo.name); */517 /* printf("Opened dir %s\n", dbinfo.name); */
465@@ -3602,8 +3709,11 @@518@@ -3602,8 +3753,11 @@
466 ".ibd")) {519 ".ibd")) {
467 /* The name ends in .ibd; try opening520 /* The name ends in .ibd; try opening
468 the file */521 the file */
@@ -475,7 +528,7 @@
475 }528 }
476 next_file_item:529 next_file_item:
477 ret = fil_file_readdir_next_file(&err,530 ret = fil_file_readdir_next_file(&err,
478@@ -3775,15 +3885,97 @@531@@ -3775,15 +3929,97 @@
479 "InnoDB: in InnoDB data dictionary"532 "InnoDB: in InnoDB data dictionary"
480 " has tablespace id %lu,\n"533 " has tablespace id %lu,\n"
481 "InnoDB: but tablespace with that id"534 "InnoDB: but tablespace with that id"
@@ -581,7 +634,7 @@
581 } else {634 } else {
582 ut_print_timestamp(stderr);635 ut_print_timestamp(stderr);
583 fputs(" InnoDB: Error: table ", stderr);636 fputs(" InnoDB: Error: table ", stderr);
584@@ -4172,7 +4364,7 @@637@@ -4172,7 +4408,7 @@
585 off the LRU list if it is in the LRU list. The caller must hold the fil_sys638 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
586 mutex. */639 mutex. */
587 static640 static
@@ -590,7 +643,7 @@
590 fil_node_prepare_for_io(643 fil_node_prepare_for_io(
591 /*====================*/644 /*====================*/
592 fil_node_t* node, /*!< in: file node */645 fil_node_t* node, /*!< in: file node */
593@@ -4192,10 +4384,13 @@646@@ -4192,10 +4428,13 @@
594 }647 }
595 648
596 if (node->open == FALSE) {649 if (node->open == FALSE) {
@@ -605,7 +658,7 @@
605 }658 }
606 659
607 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE660 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
608@@ -4208,6 +4403,8 @@661@@ -4208,6 +4447,8 @@
609 }662 }
610 663
611 node->n_pending++;664 node->n_pending++;
@@ -614,7 +667,7 @@
614 }667 }
615 668
616 /********************************************************************//**669 /********************************************************************//**
617@@ -4390,6 +4587,16 @@670@@ -4390,6 +4631,16 @@
618 671
619 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));672 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
620 673
@@ -666,7 +719,7 @@
666 Returns TRUE if a single-table tablespace does not exist in the memory cache,719 Returns TRUE if a single-table tablespace does not exist in the memory cache,
667--- a/storage/innobase/include/srv0srv.h720--- a/storage/innobase/include/srv0srv.h
668+++ b/storage/innobase/include/srv0srv.h721+++ b/storage/innobase/include/srv0srv.h
669@@ -218,6 +218,10 @@722@@ -218,6 +218,11 @@
670 extern ulong srv_max_purge_lag;723 extern ulong srv_max_purge_lag;
671 724
672 extern ulong srv_replication_delay;725 extern ulong srv_replication_delay;
@@ -674,6 +727,7 @@
674+extern ibool srv_read_only;727+extern ibool srv_read_only;
675+extern ibool srv_fake_write;728+extern ibool srv_fake_write;
676+extern ibool srv_apply_log_only;729+extern ibool srv_apply_log_only;
730+extern ibool srv_backup_mode;
677 /*-------------------------------------------*/731 /*-------------------------------------------*/
678 732
679 extern ulint srv_n_rows_inserted;733 extern ulint srv_n_rows_inserted;
@@ -824,7 +878,35 @@
824 || (recv_addr->state == RECV_BEING_PROCESSED)878 || (recv_addr->state == RECV_BEING_PROCESSED)
825 || (recv_addr->state == RECV_PROCESSED)) {879 || (recv_addr->state == RECV_PROCESSED)) {
826 880
827@@ -2308,7 +2309,7 @@881@@ -1774,6 +1775,18 @@
882 ulint zip_size = fil_space_get_zip_size(space);
883 ulint page_no = recv_addr->page_no;
884
885+ /* By now we have replayed all DDL log records from the
886+ current batch. Check if the space ID is still valid in
887+ the entry being processed, and ignore it if it is not.*/
888+ if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
889+
890+ ut_a(recv_sys->n_addrs);
891+
892+ recv_addr->state = RECV_PROCESSED;
893+ recv_sys->n_addrs--;
894+
895+ goto next;
896+ }
897 if (recv_addr->state == RECV_NOT_PROCESSED) {
898 if (!has_printed) {
899 ut_print_timestamp(stderr);
900@@ -1807,7 +1820,7 @@
901
902 mutex_enter(&(recv_sys->mutex));
903 }
904-
905+next:
906 recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
907 }
908
909@@ -2308,7 +2321,7 @@
828 || type == MLOG_FILE_RENAME910 || type == MLOG_FILE_RENAME
829 || type == MLOG_FILE_DELETE) {911 || type == MLOG_FILE_DELETE) {
830 ut_a(space);912 ut_a(space);
@@ -833,7 +915,7 @@
833 if (recv_replay_file_ops) {915 if (recv_replay_file_ops) {
834 916
835 /* In ibbackup --apply-log, replay an .ibd file917 /* In ibbackup --apply-log, replay an .ibd file
836@@ -2331,7 +2332,7 @@918@@ -2331,7 +2344,7 @@
837 ut_error;919 ut_error;
838 }920 }
839 }921 }
@@ -842,7 +924,7 @@
842 /* In normal mysqld crash recovery we do not try to924 /* In normal mysqld crash recovery we do not try to
843 replay file operations */925 replay file operations */
844 #ifdef UNIV_LOG_LSN_DEBUG926 #ifdef UNIV_LOG_LSN_DEBUG
845@@ -2748,8 +2749,11 @@927@@ -2748,8 +2761,11 @@
846 928
847 fprintf(stderr,929 fprintf(stderr,
848 "InnoDB: Doing recovery: scanned up to"930 "InnoDB: Doing recovery: scanned up to"
@@ -856,7 +938,7 @@
856 }938 }
857 }939 }
858 940
859@@ -2854,7 +2858,7 @@941@@ -2854,7 +2870,7 @@
860 "InnoDB: Reading tablespace information"942 "InnoDB: Reading tablespace information"
861 " from the .ibd files...\n");943 " from the .ibd files...\n");
862 944
@@ -865,7 +947,7 @@
865 947
866 /* If we are using the doublewrite method, we will948 /* If we are using the doublewrite method, we will
867 check if there are half-written pages in data files,949 check if there are half-written pages in data files,
868@@ -2863,12 +2867,14 @@950@@ -2863,12 +2879,14 @@
869 951
870 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {952 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
871 953
@@ -881,7 +963,7 @@
881 }963 }
882 }964 }
883 965
884@@ -3018,6 +3024,7 @@966@@ -3018,6 +3036,7 @@
885 recv_sys->recovered_lsn = checkpoint_lsn;967 recv_sys->recovered_lsn = checkpoint_lsn;
886 968
887 srv_start_lsn = checkpoint_lsn;969 srv_start_lsn = checkpoint_lsn;
@@ -889,7 +971,7 @@
889 }971 }
890 972
891 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,973 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
892@@ -3299,6 +3306,7 @@974@@ -3299,6 +3318,7 @@
893 that the data dictionary tables will be free of any locks.975 that the data dictionary tables will be free of any locks.
894 The data dictionary latch should guarantee that there is at976 The data dictionary latch should guarantee that there is at
895 most one data dictionary transaction active at a time. */977 most one data dictionary transaction active at a time. */
@@ -1011,17 +1093,18 @@
1011 secondary index entries for merge sort */1093 secondary index entries for merge sort */
1012--- a/storage/innobase/srv/srv0srv.c1094--- a/storage/innobase/srv/srv0srv.c
1013+++ b/storage/innobase/srv/srv0srv.c1095+++ b/storage/innobase/srv/srv0srv.c
1014@@ -399,6 +399,9 @@1096@@ -399,6 +399,10 @@
1015 1097
1016 UNIV_INTERN ulong srv_replication_delay = 0;1098 UNIV_INTERN ulong srv_replication_delay = 0;
1017 1099
1018+UNIV_INTERN ibool srv_read_only = FALSE;1100+UNIV_INTERN ibool srv_read_only = FALSE;
1019+UNIV_INTERN ibool srv_fake_write = FALSE;1101+UNIV_INTERN ibool srv_fake_write = FALSE;
1020+UNIV_INTERN ibool srv_apply_log_only = FALSE;1102+UNIV_INTERN ibool srv_apply_log_only = FALSE;
1103+UNIV_INTERN ibool srv_backup_mode = FALSE;
1021 /*-------------------------------------------*/1104 /*-------------------------------------------*/
1022 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;1105 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
1023 UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;1106 UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
1024@@ -1078,7 +1081,7 @@1107@@ -1078,7 +1082,7 @@
1025 }1108 }
1026 1109
1027 /* Initialize some INFORMATION SCHEMA internal structures */1110 /* Initialize some INFORMATION SCHEMA internal structures */
@@ -1030,7 +1113,7 @@
1030 }1113 }
1031 1114
1032 /*********************************************************************//**1115 /*********************************************************************//**
1033@@ -1089,6 +1092,7 @@1116@@ -1089,6 +1093,7 @@
1034 /*==========*/1117 /*==========*/
1035 {1118 {
1036 os_fast_mutex_free(&srv_conc_mutex);1119 os_fast_mutex_free(&srv_conc_mutex);
@@ -1038,7 +1121,7 @@
1038 mem_free(srv_conc_slots);1121 mem_free(srv_conc_slots);
1039 srv_conc_slots = NULL;1122 srv_conc_slots = NULL;
1040 1123
1041@@ -1102,6 +1106,7 @@1124@@ -1102,6 +1107,7 @@
1042 srv_mysql_table = NULL;1125 srv_mysql_table = NULL;
1043 1126
1044 trx_i_s_cache_free(trx_i_s_cache);1127 trx_i_s_cache_free(trx_i_s_cache);
@@ -1046,7 +1129,7 @@
1046 }1129 }
1047 1130
1048 /*********************************************************************//**1131 /*********************************************************************//**
1049@@ -1717,7 +1722,7 @@1132@@ -1717,7 +1723,7 @@
1050 }1133 }
1051 1134
1052 /* Record the lock wait time for this thread */1135 /* Record the lock wait time for this thread */
@@ -1264,3 +1347,16 @@
1264 1347
1265 UNIV_MEM_FREE(buf, n);1348 UNIV_MEM_FREE(buf, n);
1266 }1349 }
1350--- a/configure.cmake
1351+++ b/configure.cmake
1352@@ -149,7 +149,9 @@
1353 SET(CMAKE_REQUIRED_LIBRARIES
1354 ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT})
1355
1356- LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
1357+ IF(CMAKE_REQUIRED_LIBRARIES)
1358+ LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
1359+ ENDIF()
1360 LINK_LIBRARIES(${CMAKE_THREAD_LIBS_INIT})
1361
1362 OPTION(WITH_LIBWRAP "Compile with tcp wrappers support" OFF)
12671363
=== modified file 'patches/innodb56.patch'
--- patches/innodb56.patch 2013-05-03 14:12:58 +0000
+++ patches/innodb56.patch 2013-05-08 05:16:27 +0000
@@ -336,7 +336,7 @@
336 336
337+ /* Ignore .isl files on XtraBackup recovery. All tablespaces must be337+ /* Ignore .isl files on XtraBackup recovery. All tablespaces must be
338+ local. */338+ local. */
339+ if (!recv_recovery_on) {339+ if (srv_backup_mode) {
340 /* Check for a link file which locates a remote tablespace. */340 /* Check for a link file which locates a remote tablespace. */
341 remote.success = fil_open_linked_file(341 remote.success = fil_open_linked_file(
342 tablename, &remote.filepath, &remote.file);342 tablename, &remote.filepath, &remote.file);
@@ -357,7 +357,60 @@
357 ib_logf(IB_LOG_LEVEL_ERROR,357 ib_logf(IB_LOG_LEVEL_ERROR,
358 "The size of single-table tablespace file %s "358 "The size of single-table tablespace file %s "
359 "is only " UINT64PF ", should be at least %lu!",359 "is only " UINT64PF ", should be at least %lu!",
360@@ -4263,7 +4390,7 @@360@@ -4243,7 +4370,51 @@
361 }
362
363 func_exit:
364- os_file_close(fsp->file);
365+ /* We reuse file handles on the backup stage in XtraBackup to avoid
366+ inconsistencies between the file name and the actual tablespace contents
367+ if a DDL occurs between a fil_load_single_table_tablespaces() call and
368+ the actual copy operation. */
369+ if (srv_backup_mode) {
370+
371+ fil_node_t* node;
372+ fil_space_t* space;
373+
374+ mutex_enter(&fil_system->mutex);
375+
376+ space = fil_space_get_by_id(fsp->id);
377+
378+ if (space) {
379+ node = UT_LIST_GET_LAST(space->chain);
380+
381+ /* The handle will be closed by xtrabackup in
382+ xtrabackup_copy_datafile(). We set node->open to TRUE to
383+ make sure no one calls fil_node_open_file()
384+ (i.e. attempts to reopen the tablespace by name) during
385+ the backup stage. */
386+
387+ node->open = TRUE;
388+ node->handle = fsp->file;
389+
390+ /* The following is copied from fil_node_open_file() to
391+ pass fil_system validaty checks. We cannot use
392+ fil_node_open_file() directly, as that would re-open the
393+ file by name and create another file handle. */
394+
395+ fil_system->n_open++;
396+ fil_n_file_opened++;
397+
398+ if (fil_space_belongs_in_lru(space)) {
399+
400+ /* Put the node to the LRU list */
401+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
402+ }
403+ }
404+
405+ mutex_exit(&fil_system->mutex);
406+ } else {
407+
408+ os_file_close(fsp->file);
409+ }
410
411 #ifdef UNIV_HOTBACKUP
412 func_exit_after_close:
413@@ -4263,7 +4434,7 @@
361 idea is to read as much good data as we can and jump over bad data.414 idea is to read as much good data as we can and jump over bad data.
362 @return 0 if ok, -1 if error even after the retries, 1 if at the end415 @return 0 if ok, -1 if error even after the retries, 1 if at the end
363 of the directory */416 of the directory */
@@ -366,7 +419,7 @@
366 int419 int
367 fil_file_readdir_next_file(420 fil_file_readdir_next_file(
368 /*=======================*/421 /*=======================*/
369@@ -4303,7 +4430,7 @@422@@ -4303,7 +4474,7 @@
370 @return DB_SUCCESS or error number */423 @return DB_SUCCESS or error number */
371 UNIV_INTERN424 UNIV_INTERN
372 dberr_t425 dberr_t
@@ -375,7 +428,7 @@
375 /*===================================*/428 /*===================================*/
376 {429 {
377 int ret;430 int ret;
378@@ -4359,7 +4486,9 @@431@@ -4359,7 +4530,9 @@
379 "%s/%s", fil_path_to_mysql_datadir, dbinfo.name);432 "%s/%s", fil_path_to_mysql_datadir, dbinfo.name);
380 srv_normalize_path_for_win(dbpath);433 srv_normalize_path_for_win(dbpath);
381 434
@@ -386,7 +439,7 @@
386 439
387 if (dbdir != NULL) {440 if (dbdir != NULL) {
388 441
389@@ -4380,9 +4509,15 @@442@@ -4380,9 +4553,15 @@
390 && (0 == strcmp(fileinfo.name443 && (0 == strcmp(fileinfo.name
391 + strlen(fileinfo.name) - 4,444 + strlen(fileinfo.name) - 4,
392 ".ibd")445 ".ibd")
@@ -394,7 +447,7 @@
394+ /* Ignore .isl files on XtraBackup447+ /* Ignore .isl files on XtraBackup
395+ recovery, all tablespaces must be448+ recovery, all tablespaces must be
396+ local. */449+ local. */
397+ || (!recv_recovery_on &&450+ || (srv_backup_mode &&
398+ 0 == strcmp(fileinfo.name451+ 0 == strcmp(fileinfo.name
399 + strlen(fileinfo.name) - 4,452 + strlen(fileinfo.name) - 4,
400- ".isl"))) {453- ".isl"))) {
@@ -404,7 +457,7 @@
404 /* The name ends in .ibd or .isl;457 /* The name ends in .ibd or .isl;
405 try opening the file */458 try opening the file */
406 fil_load_single_table_tablespace(459 fil_load_single_table_tablespace(
407@@ -4538,6 +4673,7 @@460@@ -4538,6 +4717,7 @@
408 {461 {
409 fil_space_t* fnamespace;462 fil_space_t* fnamespace;
410 fil_space_t* space;463 fil_space_t* space;
@@ -412,7 +465,7 @@
412 465
413 ut_ad(fil_system);466 ut_ad(fil_system);
414 467
415@@ -4615,6 +4751,10 @@468@@ -4615,6 +4795,10 @@
416 if (fnamespace == NULL) {469 if (fnamespace == NULL) {
417 if (print_error_if_does_not_exist) {470 if (print_error_if_does_not_exist) {
418 fil_report_missing_tablespace(name, id);471 fil_report_missing_tablespace(name, id);
@@ -423,7 +476,7 @@
423 }476 }
424 } else {477 } else {
425 ut_print_timestamp(stderr);478 ut_print_timestamp(stderr);
426@@ -4638,6 +4778,10 @@479@@ -4638,6 +4822,10 @@
427 480
428 mutex_exit(&fil_system->mutex);481 mutex_exit(&fil_system->mutex);
429 482
@@ -434,7 +487,7 @@
434 return(FALSE);487 return(FALSE);
435 }488 }
436 489
437@@ -4728,6 +4872,7 @@490@@ -4728,6 +4916,7 @@
438 ulint page_size;491 ulint page_size;
439 ulint pages_added;492 ulint pages_added;
440 ibool success;493 ibool success;
@@ -442,7 +495,7 @@
442 495
443 ut_ad(!srv_read_only_mode);496 ut_ad(!srv_read_only_mode);
444 497
445@@ -4772,13 +4917,17 @@498@@ -4772,13 +4961,17 @@
446 goto retry;499 goto retry;
447 }500 }
448 501
@@ -461,7 +514,7 @@
461 start_page_no = space->size;514 start_page_no = space->size;
462 file_start_page_no = space->size - node->size;515 file_start_page_no = space->size - node->size;
463 516
464@@ -5024,7 +5173,7 @@517@@ -5024,7 +5217,7 @@
465 off the LRU list if it is in the LRU list. The caller must hold the fil_sys518 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
466 mutex. */519 mutex. */
467 static520 static
@@ -470,7 +523,7 @@
470 fil_node_prepare_for_io(523 fil_node_prepare_for_io(
471 /*====================*/524 /*====================*/
472 fil_node_t* node, /*!< in: file node */525 fil_node_t* node, /*!< in: file node */
473@@ -5044,9 +5193,12 @@526@@ -5044,9 +5237,12 @@
474 }527 }
475 528
476 if (node->open == FALSE) {529 if (node->open == FALSE) {
@@ -484,7 +537,7 @@
484 }537 }
485 538
486 if (node->n_pending == 0 && fil_space_belongs_in_lru(space)) {539 if (node->n_pending == 0 && fil_space_belongs_in_lru(space)) {
487@@ -5058,6 +5210,8 @@540@@ -5058,6 +5254,8 @@
488 }541 }
489 542
490 node->n_pending++;543 node->n_pending++;
@@ -493,7 +546,7 @@
493 }546 }
494 547
495 /********************************************************************//**548 /********************************************************************//**
496@@ -5259,6 +5413,16 @@549@@ -5259,6 +5457,16 @@
497 550
498 ut_ad(mode != OS_AIO_IBUF || space->purpose == FIL_TABLESPACE);551 ut_ad(mode != OS_AIO_IBUF || space->purpose == FIL_TABLESPACE);
499 552
@@ -510,7 +563,7 @@
510 node = UT_LIST_GET_FIRST(space->chain);563 node = UT_LIST_GET_FIRST(space->chain);
511 564
512 for (;;) {565 for (;;) {
513@@ -5290,7 +5454,11 @@566@@ -5290,7 +5498,11 @@
514 }567 }
515 568
516 /* Open file if closed */569 /* Open file if closed */
@@ -523,7 +576,7 @@
523 576
524 /* Check that at least the start offset is within the bounds of a577 /* Check that at least the start offset is within the bounds of a
525 single-table tablespace, including rollback tablespaces. */578 single-table tablespace, including rollback tablespaces. */
526@@ -6164,6 +6332,7 @@579@@ -6164,6 +6376,7 @@
527 return(err);580 return(err);
528 }581 }
529 582
@@ -531,7 +584,7 @@
531 /****************************************************************//**584 /****************************************************************//**
532 Generate redo logs for swapping two .ibd files */585 Generate redo logs for swapping two .ibd files */
533 UNIV_INTERN586 UNIV_INTERN
534@@ -6187,4 +6356,4 @@587@@ -6187,4 +6400,4 @@
535 0, 0, new_name, old_name, &mtr);588 0, 0, new_name, old_name, &mtr);
536 mtr_commit(&mtr);589 mtr_commit(&mtr);
537 }590 }
@@ -674,13 +727,15 @@
674 Returns TRUE if a single-table tablespace does not exist in the memory cache,727 Returns TRUE if a single-table tablespace does not exist in the memory cache,
675--- a/storage/innobase/include/srv0srv.h728--- a/storage/innobase/include/srv0srv.h
676+++ b/storage/innobase/include/srv0srv.h729+++ b/storage/innobase/include/srv0srv.h
677@@ -353,6 +353,9 @@730@@ -353,6 +353,11 @@
678 extern ulong srv_max_purge_lag_delay;731 extern ulong srv_max_purge_lag_delay;
679 732
680 extern ulong srv_replication_delay;733 extern ulong srv_replication_delay;
681+734+
682+extern ibool srv_apply_log_only;735+extern ibool srv_apply_log_only;
683+736+
737+extern ibool srv_backup_mode;
738+
684 /*-------------------------------------------*/739 /*-------------------------------------------*/
685 740
686 extern ibool srv_print_innodb_monitor;741 extern ibool srv_print_innodb_monitor;
@@ -755,7 +810,26 @@
755 || (recv_addr->state == RECV_BEING_PROCESSED)810 || (recv_addr->state == RECV_BEING_PROCESSED)
756 || (recv_addr->state == RECV_PROCESSED)) {811 || (recv_addr->state == RECV_PROCESSED)) {
757 812
758@@ -2413,7 +2415,7 @@813@@ -1868,6 +1870,18 @@
814 ulint zip_size = fil_space_get_zip_size(space);
815 ulint page_no = recv_addr->page_no;
816
817+ /* By now we have replayed all DDL log records from the
818+ current batch. Check if the space ID is still valid in
819+ the entry being processed, and ignore it if it is not.*/
820+ if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
821+
822+ ut_a(recv_sys->n_addrs);
823+
824+ recv_addr->state = RECV_PROCESSED;
825+ recv_sys->n_addrs--;
826+
827+ continue;
828+ }
829 if (recv_addr->state == RECV_NOT_PROCESSED) {
830 if (!has_printed) {
831 ib_logf(IB_LOG_LEVEL_INFO,
832@@ -2413,7 +2427,7 @@
759 || type == MLOG_FILE_RENAME833 || type == MLOG_FILE_RENAME
760 || type == MLOG_FILE_DELETE) {834 || type == MLOG_FILE_DELETE) {
761 ut_a(space);835 ut_a(space);
@@ -764,7 +838,7 @@
764 if (recv_replay_file_ops) {838 if (recv_replay_file_ops) {
765 839
766 /* In ibbackup --apply-log, replay an .ibd file840 /* In ibbackup --apply-log, replay an .ibd file
767@@ -2436,7 +2438,7 @@841@@ -2436,7 +2450,7 @@
768 ut_error;842 ut_error;
769 }843 }
770 }844 }
@@ -773,7 +847,7 @@
773 /* In normal mysqld crash recovery we do not try to847 /* In normal mysqld crash recovery we do not try to
774 replay file operations */848 replay file operations */
775 #ifdef UNIV_LOG_LSN_DEBUG849 #ifdef UNIV_LOG_LSN_DEBUG
776@@ -2863,8 +2865,14 @@850@@ -2863,8 +2877,14 @@
777 851
778 fprintf(stderr,852 fprintf(stderr,
779 "InnoDB: Doing recovery: scanned up to"853 "InnoDB: Doing recovery: scanned up to"
@@ -790,7 +864,7 @@
790 }864 }
791 }865 }
792 866
793@@ -2964,7 +2972,7 @@867@@ -2964,7 +2984,7 @@
794 ib_logf(IB_LOG_LEVEL_INFO,868 ib_logf(IB_LOG_LEVEL_INFO,
795 "Reading tablespace information from the .ibd files...");869 "Reading tablespace information from the .ibd files...");
796 870
@@ -799,7 +873,7 @@
799 873
800 /* If we are using the doublewrite method, we will874 /* If we are using the doublewrite method, we will
801 check if there are half-written pages in data files,875 check if there are half-written pages in data files,
802@@ -3456,7 +3464,8 @@876@@ -3456,7 +3476,8 @@
803 that the data dictionary tables will be free of any locks.877 that the data dictionary tables will be free of any locks.
804 The data dictionary latch should guarantee that there is at878 The data dictionary latch should guarantee that there is at
805 most one data dictionary transaction active at a time. */879 most one data dictionary transaction active at a time. */
@@ -836,16 +910,18 @@
836 tested with following crash point */910 tested with following crash point */
837--- a/storage/innobase/srv/srv0srv.cc911--- a/storage/innobase/srv/srv0srv.cc
838+++ b/storage/innobase/srv/srv0srv.cc912+++ b/storage/innobase/srv/srv0srv.cc
839@@ -349,6 +349,8 @@913@@ -349,6 +349,10 @@
840 914
841 UNIV_INTERN ulong srv_replication_delay = 0;915 UNIV_INTERN ulong srv_replication_delay = 0;
842 916
843+UNIV_INTERN ibool srv_apply_log_only = FALSE;917+UNIV_INTERN ibool srv_apply_log_only = FALSE;
844+918+
919+UNIV_INTERN ibool srv_backup_mode = FALSE;
920+
845 /*-------------------------------------------*/921 /*-------------------------------------------*/
846 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;922 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
847 UNIV_INTERN ulong srv_spin_wait_delay = 6;923 UNIV_INTERN ulong srv_spin_wait_delay = 6;
848@@ -1808,7 +1810,8 @@924@@ -1808,7 +1812,8 @@
849 if (ret == SRV_NONE925 if (ret == SRV_NONE
850 && srv_shutdown_state != SRV_SHUTDOWN_NONE926 && srv_shutdown_state != SRV_SHUTDOWN_NONE
851 && trx_purge_state() != PURGE_STATE_DISABLED927 && trx_purge_state() != PURGE_STATE_DISABLED
852928
=== modified file 'patches/xtradb51.patch'
--- patches/xtradb51.patch 2013-04-16 14:29:50 +0000
+++ patches/xtradb51.patch 2013-05-08 05:16:27 +0000
@@ -326,7 +326,60 @@
326 if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {326 if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
327 fprintf(stderr,327 fprintf(stderr,
328 "InnoDB: Error: the size of single-table tablespace"328 "InnoDB: Error: the size of single-table tablespace"
329@@ -4247,7 +4349,7 @@329@@ -4236,7 +4338,51 @@
330
331 fil_node_create(filepath, 0, space_id, FALSE);
332 func_exit:
333- os_file_close(file);
334+ /* We reuse file handles on the backup stage in XtraBackup to avoid
335+ inconsistencies between the file name and the actual tablespace contents
336+ if a DDL occurs between a fil_load_single_table_tablespaces() call and
337+ the actual copy operation. */
338+ if (srv_backup_mode) {
339+
340+ fil_node_t* node;
341+ fil_space_t* space;
342+
343+ mutex_enter(&fil_system->mutex);
344+
345+ space = fil_space_get_by_id(space_id);
346+
347+ if (space) {
348+ node = UT_LIST_GET_LAST(space->chain);
349+
350+ /* The handle will be closed by xtrabackup in
351+ xtrabackup_copy_datafile(). We set node->open to TRUE to
352+ make sure no one calls fil_node_open_file()
353+ (i.e. attempts to reopen the tablespace by name) during
354+ the backup stage. */
355+
356+ node->open = TRUE;
357+ node->handle = file;
358+
359+ /* The following is copied from fil_node_open_file() to
360+ pass fil_system validity checks. We cannot use
361+ fil_node_open_file() directly, as that would re-open the
362+ file by name and create another file handle. */
363+
364+ fil_system->n_open++;
365+
366+ if (space->purpose == FIL_TABLESPACE &&
367+ space->id != 0) {
368+
369+ /* Put the node to the LRU list */
370+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
371+ }
372+ }
373+
374+ mutex_exit(&fil_system->mutex);
375+ } else {
376+
377+ os_file_close(file);
378+ }
379 ut_free(buf2);
380 mem_free(filepath);
381 }
382@@ -4247,7 +4393,7 @@
330 idea is to read as much good data as we can and jump over bad data.383 idea is to read as much good data as we can and jump over bad data.
331 @return 0 if ok, -1 if error even after the retries, 1 if at the end384 @return 0 if ok, -1 if error even after the retries, 1 if at the end
332 of the directory */385 of the directory */
@@ -335,7 +388,7 @@
335 int388 int
336 fil_file_readdir_next_file(389 fil_file_readdir_next_file(
337 /*=======================*/390 /*=======================*/
338@@ -4291,7 +4393,7 @@391@@ -4291,7 +4437,7 @@
339 @return DB_SUCCESS or error number */392 @return DB_SUCCESS or error number */
340 UNIV_INTERN393 UNIV_INTERN
341 ulint394 ulint
@@ -344,7 +397,7 @@
344 /*===================================*/397 /*===================================*/
345 {398 {
346 int ret;399 int ret;
347@@ -4347,7 +4449,9 @@400@@ -4347,7 +4493,9 @@
348 dbinfo.name);401 dbinfo.name);
349 srv_normalize_path_for_win(dbpath);402 srv_normalize_path_for_win(dbpath);
350 403
@@ -355,7 +408,7 @@
355 408
356 if (dbdir != NULL) {409 if (dbdir != NULL) {
357 /* printf("Opened dir %s\n", dbinfo.name); */410 /* printf("Opened dir %s\n", dbinfo.name); */
358@@ -4373,8 +4477,11 @@411@@ -4373,8 +4521,11 @@
359 ".ibd")) {412 ".ibd")) {
360 /* The name ends in .ibd; try opening413 /* The name ends in .ibd; try opening
361 the file */414 the file */
@@ -368,7 +421,7 @@
368 }421 }
369 next_file_item:422 next_file_item:
370 ret = fil_file_readdir_next_file(&err,423 ret = fil_file_readdir_next_file(&err,
371@@ -4546,15 +4653,97 @@424@@ -4546,15 +4697,97 @@
372 "InnoDB: in InnoDB data dictionary"425 "InnoDB: in InnoDB data dictionary"
373 " has tablespace id %lu,\n"426 " has tablespace id %lu,\n"
374 "InnoDB: but tablespace with that id"427 "InnoDB: but tablespace with that id"
@@ -474,7 +527,7 @@
474 } else {527 } else {
475 ut_print_timestamp(stderr);528 ut_print_timestamp(stderr);
476 fputs(" InnoDB: Error: table ", stderr);529 fputs(" InnoDB: Error: table ", stderr);
477@@ -4953,7 +5142,7 @@530@@ -4953,7 +5186,7 @@
478 off the LRU list if it is in the LRU list. The caller must hold the fil_sys531 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
479 mutex. */532 mutex. */
480 static533 static
@@ -483,7 +536,7 @@
483 fil_node_prepare_for_io(536 fil_node_prepare_for_io(
484 /*====================*/537 /*====================*/
485 fil_node_t* node, /*!< in: file node */538 fil_node_t* node, /*!< in: file node */
486@@ -4973,10 +5162,13 @@539@@ -4973,10 +5206,13 @@
487 }540 }
488 541
489 if (node->open == FALSE) {542 if (node->open == FALSE) {
@@ -498,7 +551,7 @@
498 }551 }
499 552
500 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE553 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
501@@ -4989,6 +5181,8 @@554@@ -4989,6 +5225,8 @@
502 }555 }
503 556
504 node->n_pending++;557 node->n_pending++;
@@ -507,7 +560,7 @@
507 }560 }
508 561
509 /********************************************************************//**562 /********************************************************************//**
510@@ -5125,7 +5319,9 @@563@@ -5125,7 +5363,9 @@
511 ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)564 ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
512 || !ibuf_bitmap_page(zip_size, block_offset)565 || !ibuf_bitmap_page(zip_size, block_offset)
513 || sync || is_log);566 || sync || is_log);
@@ -518,7 +571,7 @@
518 || ibuf_page(space_id, zip_size, block_offset, NULL));571 || ibuf_page(space_id, zip_size, block_offset, NULL));
519 # endif /* UNIV_LOG_DEBUG */572 # endif /* UNIV_LOG_DEBUG */
520 if (sync) {573 if (sync) {
521@@ -5190,6 +5386,16 @@574@@ -5190,6 +5430,16 @@
522 575
523 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));576 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
524 577
@@ -650,13 +703,14 @@
650 return(buf);703 return(buf);
651--- a/storage/innodb_plugin/include/srv0srv.h704--- a/storage/innodb_plugin/include/srv0srv.h
652+++ b/storage/innodb_plugin/include/srv0srv.h705+++ b/storage/innodb_plugin/include/srv0srv.h
653@@ -226,6 +226,10 @@706@@ -226,6 +226,11 @@
654 707
655 extern ulong srv_replication_delay;708 extern ulong srv_replication_delay;
656 709
657+extern ibool srv_read_only;710+extern ibool srv_read_only;
658+extern ibool srv_fake_write;711+extern ibool srv_fake_write;
659+extern ibool srv_apply_log_only;712+extern ibool srv_apply_log_only;
713+extern ibool srv_backup_mode;
660+714+
661 extern long long srv_ibuf_max_size;715 extern long long srv_ibuf_max_size;
662 extern ulint srv_ibuf_active_contract;716 extern ulint srv_ibuf_active_contract;
@@ -826,7 +880,35 @@
826 ibool880 ibool
827 log_block_checksum_is_ok_or_old_format(881 log_block_checksum_is_ok_or_old_format(
828 /*===================================*/882 /*===================================*/
829@@ -2369,7 +2369,7 @@883@@ -1830,6 +1830,18 @@
884 ulint zip_size = fil_space_get_zip_size(space);
885 ulint page_no = recv_addr->page_no;
886
887+ /* By now we have replayed all DDL log records from the
888+ current batch. Check if the space ID is still valid in
889+ the entry being processed, and ignore it if it is not.*/
890+ if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
891+
892+ ut_a(recv_sys->n_addrs);
893+
894+ recv_addr->state = RECV_PROCESSED;
895+ recv_sys->n_addrs--;
896+
897+ goto next;
898+ }
899 if (recv_addr->state == RECV_NOT_PROCESSED) {
900 if (!has_printed) {
901 ut_print_timestamp(stderr);
902@@ -1863,7 +1875,7 @@
903
904 mutex_enter(&(recv_sys->mutex));
905 }
906-
907+next:
908 recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
909 }
910
911@@ -2369,7 +2381,7 @@
830 || type == MLOG_FILE_RENAME912 || type == MLOG_FILE_RENAME
831 || type == MLOG_FILE_DELETE) {913 || type == MLOG_FILE_DELETE) {
832 ut_a(space);914 ut_a(space);
@@ -835,7 +917,7 @@
835 if (recv_replay_file_ops) {917 if (recv_replay_file_ops) {
836 918
837 /* In ibbackup --apply-log, replay an .ibd file919 /* In ibbackup --apply-log, replay an .ibd file
838@@ -2392,7 +2392,7 @@920@@ -2392,7 +2404,7 @@
839 ut_error;921 ut_error;
840 }922 }
841 }923 }
@@ -844,7 +926,7 @@
844 /* In normal mysqld crash recovery we do not try to926 /* In normal mysqld crash recovery we do not try to
845 replay file operations */927 replay file operations */
846 #ifdef UNIV_LOG_LSN_DEBUG928 #ifdef UNIV_LOG_LSN_DEBUG
847@@ -2809,8 +2809,11 @@929@@ -2809,8 +2821,11 @@
848 930
849 fprintf(stderr,931 fprintf(stderr,
850 "InnoDB: Doing recovery: scanned up to"932 "InnoDB: Doing recovery: scanned up to"
@@ -858,7 +940,7 @@
858 }940 }
859 }941 }
860 942
861@@ -2913,7 +2916,7 @@943@@ -2913,7 +2928,7 @@
862 "InnoDB: Reading tablespace information"944 "InnoDB: Reading tablespace information"
863 " from the .ibd files...\n");945 " from the .ibd files...\n");
864 946
@@ -867,7 +949,7 @@
867 949
868 /* If we are using the doublewrite method, we will950 /* If we are using the doublewrite method, we will
869 check if there are half-written pages in data files,951 check if there are half-written pages in data files,
870@@ -2922,12 +2925,14 @@952@@ -2922,12 +2937,14 @@
871 953
872 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {954 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
873 955
@@ -883,7 +965,7 @@
883 }965 }
884 }966 }
885 967
886@@ -3095,6 +3100,7 @@968@@ -3095,6 +3112,7 @@
887 recv_sys->recovered_lsn = checkpoint_lsn;969 recv_sys->recovered_lsn = checkpoint_lsn;
888 970
889 srv_start_lsn = checkpoint_lsn;971 srv_start_lsn = checkpoint_lsn;
@@ -891,7 +973,7 @@
891 }973 }
892 974
893 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,975 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
894@@ -3453,6 +3459,7 @@976@@ -3453,6 +3471,7 @@
895 that the data dictionary tables will be free of any locks.977 that the data dictionary tables will be free of any locks.
896 The data dictionary latch should guarantee that there is at978 The data dictionary latch should guarantee that there is at
897 most one data dictionary transaction active at a time. */979 most one data dictionary transaction active at a time. */
@@ -1026,18 +1108,19 @@
1026 /* prototypes for new functions added to ha_innodb.cc */1108 /* prototypes for new functions added to ha_innodb.cc */
1027 ibool innobase_get_slow_log();1109 ibool innobase_get_slow_log();
1028 1110
1029@@ -415,6 +410,10 @@1111@@ -415,6 +410,11 @@
1030 1112
1031 UNIV_INTERN ulong srv_replication_delay = 0;1113 UNIV_INTERN ulong srv_replication_delay = 0;
1032 1114
1033+UNIV_INTERN ibool srv_read_only = FALSE;1115+UNIV_INTERN ibool srv_read_only = FALSE;
1034+UNIV_INTERN ibool srv_fake_write = FALSE;1116+UNIV_INTERN ibool srv_fake_write = FALSE;
1035+UNIV_INTERN ibool srv_apply_log_only = FALSE;1117+UNIV_INTERN ibool srv_apply_log_only = FALSE;
1118+UNIV_INTERN ibool srv_backup_mode = FALSE;
1036+1119+
1037 UNIV_INTERN long long srv_ibuf_max_size = 0;1120 UNIV_INTERN long long srv_ibuf_max_size = 0;
1038 UNIV_INTERN ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */1121 UNIV_INTERN ulint srv_ibuf_active_contract = 0; /* 0:disable 1:enable */
1039 UNIV_INTERN ulint srv_ibuf_accel_rate = 100;1122 UNIV_INTERN ulint srv_ibuf_accel_rate = 100;
1040@@ -1065,7 +1064,7 @@1123@@ -1065,7 +1065,7 @@
1041 }1124 }
1042 1125
1043 /* Initialize some INFORMATION SCHEMA internal structures */1126 /* Initialize some INFORMATION SCHEMA internal structures */
@@ -1046,7 +1129,7 @@
1046 }1129 }
1047 1130
1048 /*********************************************************************//**1131 /*********************************************************************//**
1049@@ -1076,6 +1075,7 @@1132@@ -1076,6 +1076,7 @@
1050 /*==========*/1133 /*==========*/
1051 {1134 {
1052 os_fast_mutex_free(&srv_conc_mutex);1135 os_fast_mutex_free(&srv_conc_mutex);
@@ -1054,7 +1137,7 @@
1054 mem_free(srv_conc_slots);1137 mem_free(srv_conc_slots);
1055 srv_conc_slots = NULL;1138 srv_conc_slots = NULL;
1056 1139
1057@@ -1089,6 +1089,7 @@1140@@ -1089,6 +1090,7 @@
1058 srv_mysql_table = NULL;1141 srv_mysql_table = NULL;
1059 1142
1060 trx_i_s_cache_free(trx_i_s_cache);1143 trx_i_s_cache_free(trx_i_s_cache);
@@ -1062,7 +1145,7 @@
1062 }1145 }
1063 1146
1064 /*********************************************************************//**1147 /*********************************************************************//**
1065@@ -2570,36 +2571,6 @@1148@@ -2570,36 +2572,6 @@
1066 old_sema = sema;1149 old_sema = sema;
1067 }1150 }
1068 1151
@@ -1143,7 +1226,6 @@
1143 1226
1144 if (srv_auto_extend_last_data_file1227 if (srv_auto_extend_last_data_file
1145 && sum_of_data_file_sizes < tablespace_size_in_header) {1228 && sum_of_data_file_sizes < tablespace_size_in_header) {
1146-
1147+ /* extend table space size aligning with header */1229+ /* extend table space size aligning with header */
1148+ ulint actual_size;1230+ ulint actual_size;
1149+ fil_extend_space_to_desired_size(&actual_size, 0, tablespace_size_in_header);1231+ fil_extend_space_to_desired_size(&actual_size, 0, tablespace_size_in_header);
@@ -1154,7 +1236,7 @@
1154+ (ulong) actual_size,1236+ (ulong) actual_size,
1155+ (ulong) tablespace_size_in_header);1237+ (ulong) tablespace_size_in_header);
1156+ }1238+ }
1157+1239
1158+#ifdef UNDEFINED1240+#ifdef UNDEFINED
1159 fprintf(stderr,1241 fprintf(stderr,
1160 "InnoDB: Error: tablespace size stored in header"1242 "InnoDB: Error: tablespace size stored in header"
@@ -1431,3 +1513,14 @@
1431 1513
1432 UNIV_MEM_FREE(buf, n);1514 UNIV_MEM_FREE(buf, n);
1433 }1515 }
1516--- a/configure.in
1517+++ b/configure.in
1518@@ -22,7 +22,7 @@
1519 AM_INIT_AUTOMAKE([1.9 tar-ustar])
1520 AC_PROG_LIBTOOL
1521
1522-AM_CONFIG_HEADER([include/config.h])
1523+AC_CONFIG_HEADERS([include/config.h])
1524
1525 # Request support for automake silent-rules if available.
1526 # Default to verbose output. One can use the configure-time
14341527
=== modified file 'patches/xtradb55.patch'
--- patches/xtradb55.patch 2013-04-16 14:29:50 +0000
+++ patches/xtradb55.patch 2013-05-08 05:16:27 +0000
@@ -325,7 +325,60 @@
325 if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {325 if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
326 fprintf(stderr,326 fprintf(stderr,
327 "InnoDB: Error: the size of single-table tablespace"327 "InnoDB: Error: the size of single-table tablespace"
328@@ -4299,7 +4402,7 @@328@@ -4288,7 +4391,51 @@
329
330 fil_node_create(filepath, 0, space_id, FALSE);
331 func_exit:
332- os_file_close(file);
333+ /* We reuse file handles on the backup stage in XtraBackup to avoid
334+ inconsistencies between the file name and the actual tablespace contents
335+ if a DDL occurs between a fil_load_single_table_tablespaces() call and
336+ the actual copy operation. */
337+ if (srv_backup_mode) {
338+
339+ fil_node_t* node;
340+ fil_space_t* space;
341+
342+ mutex_enter(&fil_system->mutex);
343+
344+ space = fil_space_get_by_id(space_id);
345+
346+ if (space) {
347+ node = UT_LIST_GET_LAST(space->chain);
348+
349+ /* The handle will be closed by xtrabackup in
350+ xtrabackup_copy_datafile(). We set node->open to TRUE to
351+ make sure no one calls fil_node_open_file()
352+ (i.e. attempts to reopen the tablespace by name) during
353+ the backup stage. */
354+
355+ node->open = TRUE;
356+ node->handle = file;
357+
358+ /* The following is copied from fil_node_open_file() to
359+ pass fil_system validity checks. We cannot use
360+ fil_node_open_file() directly, as that would re-open the
361+ file by name and create another file handle. */
362+
363+ fil_system->n_open++;
364+
365+ if (space->purpose == FIL_TABLESPACE &&
366+ space->id != 0) {
367+
368+ /* Put the node to the LRU list */
369+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
370+ }
371+ }
372+
373+ mutex_exit(&fil_system->mutex);
374+ } else {
375+
376+ os_file_close(file);
377+ }
378 ut_free(buf2);
379 mem_free(filepath);
380 }
381@@ -4299,7 +4446,7 @@
329 idea is to read as much good data as we can and jump over bad data.382 idea is to read as much good data as we can and jump over bad data.
330 @return 0 if ok, -1 if error even after the retries, 1 if at the end383 @return 0 if ok, -1 if error even after the retries, 1 if at the end
331 of the directory */384 of the directory */
@@ -334,7 +387,7 @@
334 int387 int
335 fil_file_readdir_next_file(388 fil_file_readdir_next_file(
336 /*=======================*/389 /*=======================*/
337@@ -4343,7 +4446,7 @@390@@ -4343,7 +4490,7 @@
338 @return DB_SUCCESS or error number */391 @return DB_SUCCESS or error number */
339 UNIV_INTERN392 UNIV_INTERN
340 ulint393 ulint
@@ -343,7 +396,7 @@
343 /*===================================*/396 /*===================================*/
344 {397 {
345 int ret;398 int ret;
346@@ -4399,7 +4502,9 @@399@@ -4399,7 +4546,9 @@
347 dbinfo.name);400 dbinfo.name);
348 srv_normalize_path_for_win(dbpath);401 srv_normalize_path_for_win(dbpath);
349 402
@@ -354,7 +407,7 @@
354 407
355 if (dbdir != NULL) {408 if (dbdir != NULL) {
356 /* printf("Opened dir %s\n", dbinfo.name); */409 /* printf("Opened dir %s\n", dbinfo.name); */
357@@ -4425,8 +4530,11 @@410@@ -4425,8 +4574,11 @@
358 ".ibd")) {411 ".ibd")) {
359 /* The name ends in .ibd; try opening412 /* The name ends in .ibd; try opening
360 the file */413 the file */
@@ -367,7 +420,7 @@
367 }420 }
368 next_file_item:421 next_file_item:
369 ret = fil_file_readdir_next_file(&err,422 ret = fil_file_readdir_next_file(&err,
370@@ -4598,15 +4706,97 @@423@@ -4598,15 +4750,97 @@
371 "InnoDB: in InnoDB data dictionary"424 "InnoDB: in InnoDB data dictionary"
372 " has tablespace id %lu,\n"425 " has tablespace id %lu,\n"
373 "InnoDB: but tablespace with that id"426 "InnoDB: but tablespace with that id"
@@ -473,7 +526,7 @@
473 } else {526 } else {
474 ut_print_timestamp(stderr);527 ut_print_timestamp(stderr);
475 fputs(" InnoDB: Error: table ", stderr);528 fputs(" InnoDB: Error: table ", stderr);
476@@ -5005,7 +5195,7 @@529@@ -5005,7 +5239,7 @@
477 off the LRU list if it is in the LRU list. The caller must hold the fil_sys530 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
478 mutex. */531 mutex. */
479 static532 static
@@ -482,7 +535,7 @@
482 fil_node_prepare_for_io(535 fil_node_prepare_for_io(
483 /*====================*/536 /*====================*/
484 fil_node_t* node, /*!< in: file node */537 fil_node_t* node, /*!< in: file node */
485@@ -5025,10 +5215,13 @@538@@ -5025,10 +5259,13 @@
486 }539 }
487 540
488 if (node->open == FALSE) {541 if (node->open == FALSE) {
@@ -497,7 +550,7 @@
497 }550 }
498 551
499 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE552 if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
500@@ -5041,6 +5234,8 @@553@@ -5041,6 +5278,8 @@
501 }554 }
502 555
503 node->n_pending++;556 node->n_pending++;
@@ -506,7 +559,7 @@
506 }559 }
507 560
508 /********************************************************************//**561 /********************************************************************//**
509@@ -5240,6 +5435,16 @@562@@ -5240,6 +5479,16 @@
510 563
511 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));564 ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
512 565
@@ -660,7 +713,7 @@
660 extern char srv_adaptive_flushing;713 extern char srv_adaptive_flushing;
661 714
662 715
663@@ -247,6 +246,10 @@716@@ -247,6 +246,11 @@
664 extern ulint srv_dict_size_limit;717 extern ulint srv_dict_size_limit;
665 718
666 extern ulint srv_lazy_drop_table;719 extern ulint srv_lazy_drop_table;
@@ -668,6 +721,7 @@
668+extern ibool srv_read_only;721+extern ibool srv_read_only;
669+extern ibool srv_fake_write;722+extern ibool srv_fake_write;
670+extern ibool srv_apply_log_only;723+extern ibool srv_apply_log_only;
724+extern ibool srv_backup_mode;
671 /*-------------------------------------------*/725 /*-------------------------------------------*/
672 726
673 extern ulint srv_n_rows_inserted;727 extern ulint srv_n_rows_inserted;
@@ -790,7 +844,35 @@
790 ibool844 ibool
791 log_block_checksum_is_ok_or_old_format(845 log_block_checksum_is_ok_or_old_format(
792 /*===================================*/846 /*===================================*/
793@@ -2380,7 +2380,7 @@847@@ -1842,6 +1842,18 @@
848 ulint zip_size = fil_space_get_zip_size(space);
849 ulint page_no = recv_addr->page_no;
850
851+ /* By now we have replayed all DDL log records from the
852+ current batch. Check if the space ID is still valid in
853+ the entry being processed, and ignore it if it is not.*/
854+ if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
855+
856+ ut_a(recv_sys->n_addrs);
857+
858+ recv_addr->state = RECV_PROCESSED;
859+ recv_sys->n_addrs--;
860+
861+ goto next;
862+ }
863 if (recv_addr->state == RECV_NOT_PROCESSED) {
864 if (!has_printed) {
865 ut_print_timestamp(stderr);
866@@ -1875,7 +1887,7 @@
867
868 mutex_enter(&(recv_sys->mutex));
869 }
870-
871+next:
872 recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
873 }
874
875@@ -2380,7 +2392,7 @@
794 || type == MLOG_FILE_RENAME876 || type == MLOG_FILE_RENAME
795 || type == MLOG_FILE_DELETE) {877 || type == MLOG_FILE_DELETE) {
796 ut_a(space);878 ut_a(space);
@@ -799,7 +881,7 @@
799 if (recv_replay_file_ops) {881 if (recv_replay_file_ops) {
800 882
801 /* In ibbackup --apply-log, replay an .ibd file883 /* In ibbackup --apply-log, replay an .ibd file
802@@ -2403,7 +2403,7 @@884@@ -2403,7 +2415,7 @@
803 ut_error;885 ut_error;
804 }886 }
805 }887 }
@@ -808,7 +890,7 @@
808 /* In normal mysqld crash recovery we do not try to890 /* In normal mysqld crash recovery we do not try to
809 replay file operations */891 replay file operations */
810 #ifdef UNIV_LOG_LSN_DEBUG892 #ifdef UNIV_LOG_LSN_DEBUG
811@@ -2820,8 +2820,11 @@893@@ -2820,8 +2832,11 @@
812 894
813 fprintf(stderr,895 fprintf(stderr,
814 "InnoDB: Doing recovery: scanned up to"896 "InnoDB: Doing recovery: scanned up to"
@@ -822,7 +904,7 @@
822 }904 }
823 }905 }
824 906
825@@ -2926,7 +2929,7 @@907@@ -2926,7 +2941,7 @@
826 "InnoDB: Reading tablespace information"908 "InnoDB: Reading tablespace information"
827 " from the .ibd files...\n");909 " from the .ibd files...\n");
828 910
@@ -831,7 +913,7 @@
831 913
832 /* If we are using the doublewrite method, we will914 /* If we are using the doublewrite method, we will
833 check if there are half-written pages in data files,915 check if there are half-written pages in data files,
834@@ -2935,12 +2938,14 @@916@@ -2935,12 +2950,14 @@
835 917
836 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {918 if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
837 919
@@ -847,7 +929,7 @@
847 }929 }
848 }930 }
849 931
850@@ -3109,6 +3114,7 @@932@@ -3109,6 +3126,7 @@
851 recv_sys->recovered_lsn = checkpoint_lsn;933 recv_sys->recovered_lsn = checkpoint_lsn;
852 934
853 srv_start_lsn = checkpoint_lsn;935 srv_start_lsn = checkpoint_lsn;
@@ -855,7 +937,7 @@
855 }937 }
856 938
857 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,939 contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
858@@ -3474,6 +3480,7 @@940@@ -3474,6 +3492,7 @@
859 that the data dictionary tables will be free of any locks.941 that the data dictionary tables will be free of any locks.
860 The data dictionary latch should guarantee that there is at942 The data dictionary latch should guarantee that there is at
861 most one data dictionary transaction active at a time. */943 most one data dictionary transaction active at a time. */
@@ -1017,7 +1099,7 @@
1017 1099
1018 /* Try to flush dirty pages so as to avoid IO bursts at1100 /* Try to flush dirty pages so as to avoid IO bursts at
1019 the checkpoints. */1101 the checkpoints. */
1020@@ -457,6 +451,10 @@1102@@ -457,6 +451,11 @@
1021 UNIV_INTERN ulint srv_dict_size_limit = 0;1103 UNIV_INTERN ulint srv_dict_size_limit = 0;
1022 1104
1023 UNIV_INTERN ulint srv_lazy_drop_table = 0;1105 UNIV_INTERN ulint srv_lazy_drop_table = 0;
@@ -1025,10 +1107,11 @@
1025+UNIV_INTERN ibool srv_read_only = FALSE;1107+UNIV_INTERN ibool srv_read_only = FALSE;
1026+UNIV_INTERN ibool srv_fake_write = FALSE;1108+UNIV_INTERN ibool srv_fake_write = FALSE;
1027+UNIV_INTERN ibool srv_apply_log_only = FALSE;1109+UNIV_INTERN ibool srv_apply_log_only = FALSE;
1110+UNIV_INTERN ibool srv_backup_mode = FALSE;
1028 /*-------------------------------------------*/1111 /*-------------------------------------------*/
1029 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;1112 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
1030 UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;1113 UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
1031@@ -1137,7 +1135,7 @@1114@@ -1137,7 +1136,7 @@
1032 }1115 }
1033 1116
1034 /* Initialize some INFORMATION SCHEMA internal structures */1117 /* Initialize some INFORMATION SCHEMA internal structures */
@@ -1037,7 +1120,7 @@
1037 }1120 }
1038 1121
1039 /*********************************************************************//**1122 /*********************************************************************//**
1040@@ -1148,6 +1146,7 @@1123@@ -1148,6 +1147,7 @@
1041 /*==========*/1124 /*==========*/
1042 {1125 {
1043 os_fast_mutex_free(&srv_conc_mutex);1126 os_fast_mutex_free(&srv_conc_mutex);
@@ -1045,7 +1128,7 @@
1045 mem_free(srv_conc_slots);1128 mem_free(srv_conc_slots);
1046 srv_conc_slots = NULL;1129 srv_conc_slots = NULL;
1047 1130
1048@@ -1161,6 +1160,7 @@1131@@ -1161,6 +1161,7 @@
1049 srv_mysql_table = NULL;1132 srv_mysql_table = NULL;
1050 1133
1051 trx_i_s_cache_free(trx_i_s_cache);1134 trx_i_s_cache_free(trx_i_s_cache);
@@ -1053,7 +1136,7 @@
1053 }1136 }
1054 1137
1055 /*********************************************************************//**1138 /*********************************************************************//**
1056@@ -1886,7 +1886,7 @@1139@@ -1886,7 +1887,7 @@
1057 }1140 }
1058 1141
1059 /* Record the lock wait time for this thread */1142 /* Record the lock wait time for this thread */
@@ -1062,7 +1145,7 @@
1062 }1145 }
1063 1146
1064 if (trx->was_chosen_as_deadlock_victim) {1147 if (trx->was_chosen_as_deadlock_victim) {
1065@@ -2842,36 +2842,6 @@1148@@ -2842,36 +2843,6 @@
1066 old_sema = sema;1149 old_sema = sema;
1067 }1150 }
1068 1151
10691152
=== modified file 'src/xtrabackup.cc'
--- src/xtrabackup.cc 2013-05-03 14:12:58 +0000
+++ src/xtrabackup.cc 2013-05-08 05:16:27 +0000
@@ -4035,6 +4035,55 @@
40354035
4036}4036}
40374037
4038/**********************************************************************//**
4039Closes a file. */
4040static
4041void
4042xb_fil_node_close_file(
4043/*===================*/
4044 fil_node_t* node) /*!< in: file node */
4045{
4046 ibool ret;
4047
4048 mutex_enter(&fil_system->mutex);
4049
4050 ut_ad(node);
4051 ut_a(node->n_pending == 0);
4052 ut_a(node->n_pending_flushes == 0);
4053#if MYSQL_VERSION_ID >= 50600
4054 ut_a(!node->being_extended);
4055#endif
4056
4057 if (!node->open) {
4058
4059 mutex_exit(&fil_system->mutex);
4060
4061 return;
4062 }
4063
4064 ret = os_file_close(node->handle);
4065 ut_a(ret);
4066
4067 node->open = FALSE;
4068
4069 ut_a(fil_system->n_open > 0);
4070 fil_system->n_open--;
4071#if MYSQL_VERSION_ID >= 50600
4072 fil_n_file_opened--;
4073#endif
4074
4075 if (node->space->purpose == FIL_TABLESPACE &&
4076 !trx_sys_sys_space(node->space->id)) {
4077
4078 ut_a(UT_LIST_GET_LEN(fil_system->LRU) > 0);
4079
4080 /* The node is in the LRU list, remove it */
4081 UT_LIST_REMOVE(LRU, fil_system->LRU, node);
4082 }
4083
4084 mutex_exit(&fil_system->mutex);
4085}
4086
4038/* TODO: We may tune the behavior (e.g. by fil_aio)*/4087/* TODO: We may tune the behavior (e.g. by fil_aio)*/
4039#define COPY_CHUNK 644088#define COPY_CHUNK 64
40404089
@@ -4042,7 +4091,6 @@
4042my_bool4091my_bool
4043xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, ds_ctxt_t *ds_ctxt)4092xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, ds_ctxt_t *ds_ctxt)
4044{4093{
4045 os_file_t src_file = XB_FILE_UNDEFINED;
4046 MY_STAT src_stat;4094 MY_STAT src_stat;
4047 char dst_name[FN_REFLEN];4095 char dst_name[FN_REFLEN];
4048 char meta_name[FN_REFLEN];4096 char meta_name[FN_REFLEN];
@@ -4093,34 +4141,47 @@
4093 strncpy(dst_name, xb_get_relative_path(node_path, is_system),4141 strncpy(dst_name, xb_get_relative_path(node_path, is_system),
4094 sizeof(dst_name));4142 sizeof(dst_name));
40954143
4096 /* open src_file*/4144 /* We should already have a tablespace handle created by
4097 src_file = xb_file_create_no_error_handling(node_path,4145 fil_load_single_table_tablespace() unless it is a system tablespace. */
4098 OS_FILE_OPEN,4146 if (is_system) {
4099 OS_FILE_READ_ONLY,4147
4100 &success);4148 node->handle =
4101 if (!success) {4149 xb_file_create_no_error_handling(node_path,
4102 /* The following call prints an error message */4150 OS_FILE_OPEN,
4103 os_file_get_last_error(TRUE);4151 OS_FILE_READ_ONLY,
41044152 &success);
4105 msg("[%02u] xtrabackup: Warning: cannot open %s\n"4153 if (!success) {
4106 "[%02u] xtrabackup: Warning: We assume the "4154
4107 "table was dropped or renamed during "4155 msg("[%02u] xtrabackup: error: cannot open "
4108 "xtrabackup execution and ignore the file.\n",4156 "system tablespace %s\n", thread_n, node_path);
4109 thread_n, node_path, thread_n);4157 goto error;
4110 goto skip;4158 }
4159
4160 mutex_enter(&fil_system->mutex);
4161
4162 node->open = TRUE;
4163
4164 fil_system->n_open++;
4165#if MYSQL_VERSION_ID >= 50600
4166 fil_n_file_opened++;
4167#endif
4168
4169 mutex_exit(&fil_system->mutex);
4111 }4170 }
41124171
4113 xb_file_set_nocache(src_file, node_path, "OPEN");4172 ut_ad(node->open);
4173
4174 xb_file_set_nocache(node->handle, node_path, "OPEN");
41144175
4115#ifdef USE_POSIX_FADVISE4176#ifdef USE_POSIX_FADVISE
4116 posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);4177 posix_fadvise(node->handle, 0, 0, POSIX_FADV_SEQUENTIAL);
4117#endif4178#endif
41184179
4119#ifndef INNODB_VERSION_SHORT4180#ifndef INNODB_VERSION_SHORT
4120 page_size = UNIV_PAGE_SIZE;4181 page_size = UNIV_PAGE_SIZE;
4121 page_size_shift = UNIV_PAGE_SIZE_SHIFT;4182 page_size_shift = UNIV_PAGE_SIZE_SHIFT;
4122#else4183#else
4123 info.zip_size = xb_get_zip_size(src_file);4184 info.zip_size = xb_get_zip_size(node->handle);
4124 if (info.zip_size == ULINT_UNDEFINED) {4185 if (info.zip_size == ULINT_UNDEFINED) {
4125 goto skip;4186 goto skip;
4126 } else if (info.zip_size) {4187 } else if (info.zip_size) {
@@ -4164,10 +4225,10 @@
4164 } else4225 } else
4165 info.page_size = 0;4226 info.page_size = 0;
41664227
4167 if (my_stat(node_path, &src_stat, MYF(MY_WME)) == NULL) {4228 if (my_fstat(node->handle, &src_stat, MYF(MY_WME))) {
4168 msg("[%02u] xtrabackup: Warning: cannot stat %s\n",4229 msg("[%02u] xtrabackup: Warning: cannot stat %s\n",
4169 thread_n, node_path);4230 thread_n, node_path);
4170 goto skip;4231 goto error;
4171 }4232 }
4172 dstfile = ds->open(ds_ctxt, dst_name, &src_stat);4233 dstfile = ds->open(ds_ctxt, dst_name, &src_stat);
4173 if (dstfile == NULL) {4234 if (dstfile == NULL) {
@@ -4197,7 +4258,7 @@
4197 * page_size + UNIV_PAGE_SIZE));4258 * page_size + UNIV_PAGE_SIZE));
4198 page = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));4259 page = static_cast<byte *>(ut_align(buf2, UNIV_PAGE_SIZE));
41994260
4200 success = xb_os_file_read(src_file, page, 0, UNIV_PAGE_SIZE);4261 success = xb_os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE);
4201 if (!success) {4262 if (!success) {
4202 goto error;4263 goto error;
4203 }4264 }
@@ -4218,13 +4279,13 @@
4218read_retry:4279read_retry:
4219 xtrabackup_io_throttling();4280 xtrabackup_io_throttling();
42204281
4221 success = xb_os_file_read(src_file, page, offset, chunk);4282 success = xb_os_file_read(node->handle, page, offset, chunk);
4222 if (!success) {4283 if (!success) {
4223 goto error;4284 goto error;
4224 }4285 }
42254286
4226#ifdef USE_POSIX_FADVISE4287#ifdef USE_POSIX_FADVISE
4227 posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);4288 posix_fadvise(node->handle, 0, 0, POSIX_FADV_DONTNEED);
4228#endif4289#endif
42294290
4230 /* check corruption and retry */4291 /* check corruption and retry */
@@ -4349,17 +4410,17 @@
43494410
4350 /* close */4411 /* close */
4351 msg("[%02u] ...done\n", thread_n);4412 msg("[%02u] ...done\n", thread_n);
4352 if (!node->open) {4413
4353 os_file_close(src_file);4414 xb_fil_node_close_file(node);
4354 }4415
4355 ds->close(dstfile);4416 ds->close(dstfile);
4356 if (incremental_buffer_base)4417 if (incremental_buffer_base)
4357 ut_free(incremental_buffer_base);4418 ut_free(incremental_buffer_base);
4358 ut_free(buf2);4419 ut_free(buf2);
4359 return(FALSE);4420 return(FALSE);
4360error:4421error:
4361 if (src_file != XB_FILE_UNDEFINED && !node->open)4422 xb_fil_node_close_file(node);
4362 os_file_close(src_file);4423
4363 if (dstfile != NULL)4424 if (dstfile != NULL)
4364 ds->close(dstfile);4425 ds->close(dstfile);
4365 if (incremental_buffer_base)4426 if (incremental_buffer_base)
@@ -4371,8 +4432,8 @@
4371 return(TRUE); /*ERROR*/4432 return(TRUE); /*ERROR*/
43724433
4373skip:4434skip:
4374 if (src_file != XB_FILE_UNDEFINED && !node->open)4435 xb_fil_node_close_file(node);
4375 os_file_close(src_file);4436
4376 if (dstfile != NULL)4437 if (dstfile != NULL)
4377 ds->close(dstfile);4438 ds->close(dstfile);
4378 if (incremental_buffer_base)4439 if (incremental_buffer_base)
@@ -4789,7 +4850,7 @@
4789 srv_n_file_io_threads,4850 srv_n_file_io_threads,
4790 SRV_MAX_N_PENDING_SYNC_IOS);4851 SRV_MAX_N_PENDING_SYNC_IOS);
47914852
4792 fil_init(srv_max_n_open_files);4853 fil_init(LONG_MAX);
4793#else4854#else
4794#if MYSQL_VERSION_ID >= 506004855#if MYSQL_VERSION_ID >= 50600
4795 srv_n_file_io_threads = srv_n_read_io_threads;4856 srv_n_file_io_threads = srv_n_read_io_threads;
@@ -4803,8 +4864,7 @@
4803 srv_n_write_io_threads,4864 srv_n_write_io_threads,
4804 SRV_MAX_N_PENDING_SYNC_IOS);4865 SRV_MAX_N_PENDING_SYNC_IOS);
48054866
4806 fil_init(srv_file_per_table ? 50000 : 5000,4867 fil_init(srv_file_per_table ? 50000 : 5000, LONG_MAX);
4807 srv_max_n_open_files);
4808#endif4868#endif
48094869
4810 fsp_init();4870 fsp_init();
@@ -4848,11 +4908,6 @@
4848 return(DB_ERROR);4908 return(DB_ERROR);
4849 }4909 }
48504910
4851 err = fil_load_single_table_tablespaces(xb_check_if_open_tablespace);
4852 if (err != DB_SUCCESS) {
4853 return(err);
4854 }
4855
4856#if MYSQL_VERSION_ID >= 506004911#if MYSQL_VERSION_ID >= 50600
4857 /* Add separate undo tablespaces to fil_system */4912 /* Add separate undo tablespaces to fil_system */
48584913
@@ -4865,6 +4920,15 @@
4865 }4920 }
4866#endif4921#endif
48674922
4923 /* It is important to call fil_load_single_table_tablespace() after
4924 srv_undo_tablespaces_init(), because fil_is_user_tablespace_id() *
4925 relies on srv_undo_tablespaces_open to be properly initialized */
4926
4927 err = fil_load_single_table_tablespaces(xb_check_if_open_tablespace);
4928 if (err != DB_SUCCESS) {
4929 return(err);
4930 }
4931
4868 return(DB_SUCCESS);4932 return(DB_SUCCESS);
4869}4933}
48704934
@@ -5278,6 +5342,8 @@
5278 srv_read_only = TRUE;5342 srv_read_only = TRUE;
5279#endif5343#endif
52805344
5345 srv_backup_mode = TRUE;
5346
5281 /* initialize components */5347 /* initialize components */
5282 if(innodb_init_param())5348 if(innodb_init_param())
5283 exit(EXIT_FAILURE);5349 exit(EXIT_FAILURE);
52845350
=== modified file 'test/inc/common.sh'
--- test/inc/common.sh 2013-05-01 20:09:28 +0000
+++ test/inc/common.sh 2013-05-08 05:16:27 +0000
@@ -442,6 +442,25 @@
442 $MYSQL $MYSQL_ARGS -Ns -e "CHECKSUM TABLE $2 EXTENDED" $1 | awk {'print $2'}442 $MYSQL $MYSQL_ARGS -Ns -e "CHECKSUM TABLE $2 EXTENDED" $1 | awk {'print $2'}
443}443}
444444
445##########################################################################
446# Dumps a given database using mysqldump #
447##########################################################################
448function record_db_state()
449{
450 $MYSQLDUMP $MYSQL_ARGS -t --compact $1 >"$topdir/tmp/$1_old.sql"
451}
452
453
454##########################################################################
455# Compares the current dump of a given database with a state previously #
456# captured with record_db_state(). #
457##########################################################################
458function verify_db_state()
459{
460 $MYSQLDUMP $MYSQL_ARGS -t --compact $1 >"$topdir/tmp/$1_new.sql"
461 diff -u "$topdir/tmp/$1_old.sql" "$topdir/tmp/$1_new.sql"
462}
463
445########################################################################464########################################################################
446# Workarounds for a bug in grep 2.10 when grep -q file > file would465# Workarounds for a bug in grep 2.10 when grep -q file > file would
447# result in a failure.466# result in a failure.
448467
=== renamed file 'test/t/bug722638.sh' => 'test/t/ddl.sh'
--- test/t/bug722638.sh 2012-06-04 18:29:48 +0000
+++ test/t/ddl.sh 2013-05-08 05:16:27 +0000
@@ -1,7 +1,9 @@
1########################################################################1############################################################################
2# Bug #722638: xtrabackup: taking backup while tables are droped and 2# Bug #722638: xtrabackup: taking backup while tables are droped and
3# created breaks backup3# created breaks backup
4########################################################################4#
5# Bug #1079700: Issues with renaming/rotating tables during the backup stage
6############################################################################
57
6. inc/common.sh8. inc/common.sh
79
@@ -10,7 +12,11 @@
10 exit $SKIPPED_EXIT_CODE12 exit $SKIPPED_EXIT_CODE
11fi13fi
1214
13start_server --innodb_file_per_table15MYSQLD_EXTRA_MY_CNF_OPTS="
16innodb_file_per_table
17"
18
19start_server
1420
15run_cmd $MYSQL $MYSQL_ARGS test <<EOF21run_cmd $MYSQL $MYSQL_ARGS test <<EOF
1622
@@ -26,8 +32,19 @@
26CREATE TABLE t4_old(a INT) ENGINE=InnoDB;32CREATE TABLE t4_old(a INT) ENGINE=InnoDB;
27INSERT INTO t4_old VALUES (1), (2), (3);33INSERT INTO t4_old VALUES (1), (2), (3);
2834
35CREATE TABLE t5(a INT) ENGINE=InnoDB;
36INSERT INTO t5 VALUES (1), (2), (3);
37
38CREATE TABLE t6(c CHAR(1)) ENGINE=InnoDB;
39INSERT INTO t6 VALUES ('a'), ('b'), ('c');
40
29EOF41EOF
3042
43# Make a checkpoint so that original tablespace creation events are not in the
44# xtrabackup log
45shutdown_server
46start_server
47
31mkdir -p $topdir/backup48mkdir -p $topdir/backup
3249
33# Backup50# Backup
@@ -70,13 +87,18 @@
70ALTER TABLE t4_old RENAME t4;87ALTER TABLE t4_old RENAME t4;
71INSERT INTO t4 VALUES (7), (8), (9);88INSERT INTO t4 VALUES (7), (8), (9);
7289
90INSERT INTO t5 VALUES (4), (5), (6);
91INSERT INTO t6 VALUES ('d'), ('e'), ('f');
92
93# Rotate tables t5 and t6
94RENAME TABLE t5 TO temp, t6 TO t5, temp TO t6;
95
96INSERT INTO t5 VALUES ('g'), ('h'), ('i');
97INSERT INTO t6 VALUES (7), (8), (9);
98
73EOF99EOF
74100
75# Calculate checksums101record_db_state test
76checksum_t1=`checksum_table test t1`
77checksum_t2=`checksum_table test t2`
78checksum_t3=`checksum_table test t3`
79checksum_t4=`checksum_table test t4`
80102
81# Resume xtrabackup103# Resume xtrabackup
82vlog "Resuming xtrabackup"104vlog "Resuming xtrabackup"
@@ -84,6 +106,8 @@
84106
85run_cmd wait $job_pid107run_cmd wait $job_pid
86108
109# exit 1
110
87# Prepare111# Prepare
88xtrabackup --datadir=$mysql_datadir --prepare --target-dir=$topdir/backup112xtrabackup --datadir=$mysql_datadir --prepare --target-dir=$topdir/backup
89113
@@ -94,25 +118,7 @@
94 $mysql_datadir/test/*.ibd118 $mysql_datadir/test/*.ibd
95cp -r $topdir/backup/* $mysql_datadir119cp -r $topdir/backup/* $mysql_datadir
96120
97start_server --innodb_file_per_table121start_server
98122
99# Verify checksums123# Verify backup
100checksum_t1_new=`checksum_table test t1`124verify_db_state test
101checksum_t2_new=`checksum_table test t2`
102checksum_t3_new=`checksum_table test t3`
103checksum_t4_new=`checksum_table test t4`
104vlog "Checksums (old/new):"
105vlog "t1: $checksum_t1/$checksum_t1_new"
106vlog "t2: $checksum_t2/$checksum_t2_new"
107vlog "t3: $checksum_t3/$checksum_t3_new"
108vlog "t4: $checksum_t4/$checksum_t4_new"
109
110if [ "$checksum_t1" = "$checksum_t1_new" -a \
111 "$checksum_t2" = "$checksum_t2_new" -a \
112 "$checksum_t3" = "$checksum_t3_new" -a \
113 "$checksum_t4" = "$checksum_t4_new" ]; then
114 exit 0
115fi
116
117vlog "Checksums do not match"
118exit -1
119125
=== modified file 'test/testrun.sh'
--- test/testrun.sh 2013-04-27 18:46:54 +0000
+++ test/testrun.sh 2013-05-08 05:16:27 +0000
@@ -70,6 +70,7 @@
70 find_program MYSQLD mysqld $MYSQL_BASEDIR/bin/ $MYSQL_BASEDIR/libexec70 find_program MYSQLD mysqld $MYSQL_BASEDIR/bin/ $MYSQL_BASEDIR/libexec
71 find_program MYSQL mysql $MYSQL_BASEDIR/bin71 find_program MYSQL mysql $MYSQL_BASEDIR/bin
72 find_program MYSQLADMIN mysqladmin $MYSQL_BASEDIR/bin72 find_program MYSQLADMIN mysqladmin $MYSQL_BASEDIR/bin
73 find_program MYSQLDUMP mysqldump $MYSQL_BASEDIR/bin
7374
74 # Check if we are running from a source tree and, if so, set PATH 75 # Check if we are running from a source tree and, if so, set PATH
75 # appropriately76 # appropriately
@@ -85,9 +86,10 @@
85 else86 else
86 LD_LIBRARY_PATH=$MYSQL_BASEDIR/lib/mysql:$LD_LIBRARY_PATH87 LD_LIBRARY_PATH=$MYSQL_BASEDIR/lib/mysql:$LD_LIBRARY_PATH
87 fi88 fi
89 DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH"
8890
89 export TEST_BASEDIR PORT_BASE TAR MYSQL_BASEDIR MYSQL MYSQLD MYSQLADMIN \91 export TEST_BASEDIR PORT_BASE TAR MYSQL_BASEDIR MYSQL MYSQLD MYSQLADMIN \
90MYSQL_INSTALL_DB PATH LD_LIBRARY_PATH92MYSQL_INSTALL_DB PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH MYSQLDUMP
91}93}
9294
9395
9496
=== modified file 'utils/build.sh'
--- utils/build.sh 2013-04-30 07:33:04 +0000
+++ utils/build.sh 2013-05-08 05:16:27 +0000
@@ -44,7 +44,13 @@
44-DUNIV_DEBUG_THREAD_CREATION -DUNIV_DEBUG_LOCK_VALIDATE -DUNIV_DEBUG_PRINT \44-DUNIV_DEBUG_THREAD_CREATION -DUNIV_DEBUG_LOCK_VALIDATE -DUNIV_DEBUG_PRINT \
45-DUNIV_DEBUG_FILE_ACCESS -DUNIV_SEARCH_DEBUG -DUNIV_LOG_LSN_DEBUG \45-DUNIV_DEBUG_FILE_ACCESS -DUNIV_SEARCH_DEBUG -DUNIV_LOG_LSN_DEBUG \
46-DUNIV_ZIP_DEBUG -DUNIV_AHI_DEBUG -DUNIV_SQL_DEBUG -DUNIV_AIO_DEBUG \46-DUNIV_ZIP_DEBUG -DUNIV_AHI_DEBUG -DUNIV_SQL_DEBUG -DUNIV_AIO_DEBUG \
47-DUNIV_LRU_DEBUG -DUNIV_BUF_DEBUG -DUNIV_HASH_DEBUG -DUNIV_LIST_DEBUG -DUNIV_IBUF_DEBUG"47-DUNIV_LRU_DEBUG -DUNIV_BUF_DEBUG -DUNIV_HASH_DEBUG -DUNIV_IBUF_DEBUG"
48
49 if [ "$type" = "innodb56" ]
50 then
51 innodb_extra_debug="$innodb_extra_debug -DUNIV_LIST_DEBUG"
52 fi
53
48 export CFLAGS="$CFLAGS -g -O0 $innodb_extra_debug -DSAFE_MUTEX -DSAFEMALLOC"54 export CFLAGS="$CFLAGS -g -O0 $innodb_extra_debug -DSAFE_MUTEX -DSAFEMALLOC"
49 export CXXFLAGS="$CXXFLAGS -g -O0 $innodb_extra_debug -DSAFE_MUTEX -DSAFEMALLOC"55 export CXXFLAGS="$CXXFLAGS -g -O0 $innodb_extra_debug -DSAFE_MUTEX -DSAFEMALLOC"
50 extra_config_51="--with-debug=full"56 extra_config_51="--with-debug=full"

Subscribers

People subscribed via source and target branches