MDEV-13825 mariabackup --lock-ddl-per-table does not properly lock

FULLTEXT auxiliary tables

Change the logic to take mdl lock on all tables before tablespaces are
copied, rather than  lock every single tablespace just before it is
copied.
This commit is contained in:
Vladislav Vaintroub 2018-01-23 09:12:25 +00:00
parent 29eeb527fd
commit 87db5eb813

View File

@ -433,6 +433,22 @@ datafiles_iter_free(datafiles_iter_t *it)
free(it); free(it);
} }
void mdl_lock_all()
{
mdl_lock_init();
datafiles_iter_t *it = datafiles_iter_new(fil_system);
if (!it)
return;
while (fil_node_t *node = datafiles_iter_next(it)){
if (fil_is_user_tablespace_id(node->space->id)
&& check_if_skip_table(node->space->name))
continue;
mdl_lock_table(node->space->id);
}
datafiles_iter_free(it);
}
/* ======== Date copying thread context ======== */ /* ======== Date copying thread context ======== */
typedef struct { typedef struct {
@ -2199,10 +2215,6 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
return(FALSE); return(FALSE);
} }
if (opt_lock_ddl_per_table) {
mdl_lock_table(node->space->id);
}
if (!changed_page_bitmap) { if (!changed_page_bitmap) {
read_filter = &rf_pass_through; read_filter = &rf_pass_through;
} }
@ -3562,9 +3574,7 @@ xtrabackup_backup_func()
"or RENAME TABLE during the backup, inconsistent backup will be " "or RENAME TABLE during the backup, inconsistent backup will be "
"produced.\n"); "produced.\n");
if (opt_lock_ddl_per_table) {
mdl_lock_init();
}
/* initialize components */ /* initialize components */
if(innodb_init_param()) { if(innodb_init_param()) {
@ -3879,6 +3889,10 @@ reread_log_header:
"files transfer\n", xtrabackup_parallel); "files transfer\n", xtrabackup_parallel);
} }
if (opt_lock_ddl_per_table) {
mdl_lock_all();
}
it = datafiles_iter_new(fil_system); it = datafiles_iter_new(fil_system);
if (it == NULL) { if (it == NULL) {
msg("mariabackup: Error: datafiles_iter_new() failed.\n"); msg("mariabackup: Error: datafiles_iter_new() failed.\n");