summaryrefslogtreecommitdiff
path: root/extra/mariabackup/xtrabackup.cc
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2017-09-11 16:45:36 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2017-09-12 05:57:05 +0000
commit31774f0ede81d77d889061324930d3d0066c653a (patch)
treeb9131beffe7791a39a21434dcdfe492543a9f3a7 /extra/mariabackup/xtrabackup.cc
parent6b5c0effe43d5cfd19d3aff0fdb5fb6f1b6d41d3 (diff)
downloadmariadb-git-31774f0ede81d77d889061324930d3d0066c653a.tar.gz
MDEV-13563 lock DDL for mariabackup in 10.2
Implement lock-ddl-per-table option that locks tables before it is copied to backup, and helds the lock until backup finished The "DDL-lock" itself is implemented as "SELECT * from <table> LIMIT 0", inside a transaction, and "COMMIT" of this transaction is the DDL-unlock.
Diffstat (limited to 'extra/mariabackup/xtrabackup.cc')
-rw-r--r--extra/mariabackup/xtrabackup.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 65aa913cc29..5d8bc7eaaf3 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -296,6 +296,8 @@ my_bool opt_noversioncheck = FALSE;
my_bool opt_no_backup_locks = FALSE;
my_bool opt_decompress = FALSE;
+my_bool opt_lock_ddl_per_table = FALSE;
+
static const char *binlog_info_values[] = {"off", "lockless", "on", "auto",
NullS};
static TYPELIB binlog_info_typelib = {array_elements(binlog_info_values)-1, "",
@@ -537,7 +539,8 @@ enum options_xtrabackup
OPT_XTRA_TABLES_EXCLUDE,
OPT_XTRA_DATABASES_EXCLUDE,
- OPT_PROTOCOL
+ OPT_PROTOCOL,
+ OPT_LOCK_DDL_PER_TABLE
};
struct my_option xb_client_options[] =
@@ -1072,6 +1075,11 @@ struct my_option xb_server_options[] =
(G_PTR*) &xb_open_files_limit, (G_PTR*) &xb_open_files_limit, 0, GET_ULONG,
REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0},
+ {"lock-ddl-per-table", OPT_LOCK_DDL_PER_TABLE, "Lock DDL for each table "
+ "before xtrabackup starts to copy it and until the backup is completed.",
+ (uchar*) &opt_lock_ddl_per_table, (uchar*) &opt_lock_ddl_per_table, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -2205,6 +2213,10 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
return(FALSE);
}
+ if (opt_lock_ddl_per_table) {
+ mdl_lock_table(node->space->id);
+ }
+
if (!changed_page_bitmap) {
read_filter = &rf_pass_through;
}
@@ -3552,6 +3564,10 @@ xtrabackup_backup_func()
"or RENAME TABLE during the backup, inconsistent backup will be "
"produced.\n");
+ if (opt_lock_ddl_per_table) {
+ mdl_lock_init();
+ }
+
/* initialize components */
if(innodb_init_param()) {
fail:
@@ -3930,6 +3946,10 @@ reread_log_header:
goto fail;
}
+ if (opt_lock_ddl_per_table) {
+ mdl_unlock_all();
+ }
+
xtrabackup_destroy_datasinks();
msg("xtrabackup: Redo log (from LSN " LSN_PF " to " LSN_PF