forked from percona/percona-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://blueprints.launchpad.net/percona-server/+spec/backup-safe-binlog-info One inefficiency of the backup locks feature is that even though LOCK TABLES FOR BACKUP as a light-weight FTWRL alternative does not affect DML statements updating InnoDB tables, LOCK BINLOG FOR BACKUP does affect them by blocking commits. XtraBackup uses LOCK BINLOG FOR BACKUP to: 1. retrieve consistent binary log coordinates with SHOW MASTER STATUS. More precisely, binary log coordinates must be consistent with the REDO log copy and non-transactional tables. Therefore, no updates can be done to non-transactional tables (this is achieved by an active LOCK TABLES FOR BACKUP lock), and no commits can be performed between SHOW MASTER STATUS and finalizing the redo log copy, which is achieved by LOCK BINLOG FOR BACKUP. 2. retrieve consistent master connection information for a replication slave. More precisely, the binary log coordinates on the master as reported by SHOW SLAVE STATUS must be consistent with the REDO log copy, so LOCK BINLOG FOR BACKUP also block the I/O replication thread. 3. For a GTID-enabled PXC node, the last binary log file must be included into an SST snapshot. Which is a rather artificial limitation on the WSREP side, but still XtraBackup obeys it by blocking commits with LOCK BINLOG FOR BACKUP to ensure the integrity of the binary log file copy. Depending on the write rate on the server, finalizing the REDO log copy may take a long time, so blocking commits for that duration may still affect server availability considerably. This task is to make the necessary server-side change to make it possible for XtraBackup to avoid LOCK BINLOG FOR BINLOG in case percona#1, when cases percona#2 and percona#3 do not apply, i.e. when no --slave-info is requested by the XtraBackup options and the server is not a GTID-enabled PXC node. Lifting limitations for cases percona#2 and percona#3 is also possible, but that is outside the scope of this task. The idea of the optimization is that even though InnoDB provides a transactional storage for the binary log information (i.e. current file name and offset), it cannot be fully trusted by XtraBackup, because that information is only updated on an InnoDB commit operation. Which means if the last operation before LOCK TABLES FOR BACKUP was an update to a non-transactional storage engine, and no InnoDB commits occur before the backup is finalized by XtraBackup, the InnoDB system header will contain stale binary log coordinates. One way to fix that would be to force binlog coordinates update in the InnoDB system header on each update, regardless of the involved storage engine(s). This is what a Galera node does to ensure XID consistency which is stored in the same way as binary log coordinates: it forces XID update in the InnoDB system header on each TOI operation, in particular on each non-transactional update. Another approach is less invasive: XtraBackup blocks all non-transactional updates with LOCK TABLES FOR BACKUP anyway, so instead of having all non-transactional updates flush binlog coordinates to InnoDB unconditionally, LTFB can be modified to flush (and redo-log) the current binlog coordinates to InnoDB. In which case binlog coordinates provided by InnoDB will be consistent with REDO log under any circumstances. This patch implements the latter approach.
- Loading branch information
Showing
12 changed files
with
167 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TABLE t1 (a INT) ENGINE=InnoDB; | ||
INSERT INTO t1 VALUES (1); | ||
CREATE TABLE t2(a INT) ENGINE=MyISAM; | ||
INSERT INTO t2 VALUES(2); | ||
LOCK TABLES FOR BACKUP; | ||
DROP TABLE t1; |
11 changes: 11 additions & 0 deletions
11
mysql-test/suite/sys_vars/r/have_backup_safe_binlog_info_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SELECT @@GLOBAL.have_backup_safe_binlog_info="YES"; | ||
@@GLOBAL.have_backup_safe_binlog_info="YES" | ||
1 | ||
SELECT @@SESSION.have_backup_safe_binlog_info; | ||
ERROR HY000: Variable 'have_backup_safe_binlog_info' is a GLOBAL variable | ||
SHOW GLOBAL VARIABLES LIKE 'have_backup_safe_binlog_info'; | ||
Variable_name Value | ||
have_backup_safe_binlog_info YES | ||
SHOW SESSION VARIABLES LIKE 'have_backup_safe_binlog_info'; | ||
Variable_name Value | ||
have_backup_safe_binlog_info YES |
7 changes: 7 additions & 0 deletions
7
mysql-test/suite/sys_vars/t/have_backup_safe_binlog_info_basic.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT @@GLOBAL.have_backup_safe_binlog_info="YES"; | ||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
SELECT @@SESSION.have_backup_safe_binlog_info; | ||
|
||
SHOW GLOBAL VARIABLES LIKE 'have_backup_safe_binlog_info'; | ||
|
||
SHOW SESSION VARIABLES LIKE 'have_backup_safe_binlog_info'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
######################################################################## | ||
# Tests for the backup-safe binlog info feature | ||
######################################################################## | ||
|
||
--source include/not_embedded.inc | ||
--source include/have_innodb.inc | ||
--source include/have_log_bin.inc | ||
|
||
CREATE TABLE t1 (a INT) ENGINE=InnoDB; | ||
INSERT INTO t1 VALUES (1); | ||
|
||
CREATE TABLE t2(a INT) ENGINE=MyISAM; | ||
INSERT INTO t2 VALUES(2); | ||
|
||
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) | ||
--let $binlog_pos= query_get_value(SHOW MASTER STATUS, Position, 1) | ||
|
||
LOCK TABLES FOR BACKUP; | ||
|
||
--exec echo "restart: --log-error=$MYSQLTEST_VARDIR/log/my_restart.err" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect | ||
--shutdown_server 0 | ||
|
||
--enable_reconnect | ||
--source include/wait_until_connected_again.inc | ||
--disable_reconnect | ||
|
||
--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err | ||
--let SEARCH_PATTERN= InnoDB: Last MySQL binlog file position 0 $binlog_pos, file name $binlog_file | ||
--source include/search_pattern_in_file.inc | ||
|
||
--remove_file $SEARCH_FILE | ||
|
||
DROP TABLE t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters