Commit 3efed753 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Fix lock_ddl_per_table handling in mariabackup.


mariabackup.lock_ddl_per_table was broken, after MDEV-17772 got fixed.
Fix removes MDL waiter killer, it is is not needed anymore.
parent fcb6bb4b
......@@ -871,83 +871,6 @@ stop_query_killer()
}
/*
Killing connections that wait for MDL lock.
If lock-ddl-per-table is used, there can be some DDL statements
FLUSH TABLES would hang infinitely, if DDL statements are waiting for
MDL lock, which mariabackup currently holds. Therefore we start killing
those statements from a dedicated thread, until FLUSH TABLES WITH READ LOCK
succeeds.
*/
static os_event_t mdl_killer_stop_event;
static os_event_t mdl_killer_finished_event;
static
os_thread_ret_t
DECLARE_THREAD(kill_mdl_waiters_thread(void *))
{
MYSQL *mysql;
if ((mysql = xb_mysql_connect()) == NULL) {
msg("Error: kill mdl waiters thread failed to connect\n");
goto stop_thread;
}
for(;;){
if (os_event_wait_time(mdl_killer_stop_event, 1000) == 0)
break;
MYSQL_RES *result = xb_mysql_query(mysql,
"SELECT ID, COMMAND, INFO FROM INFORMATION_SCHEMA.PROCESSLIST "
" WHERE State='Waiting for table metadata lock'",
true, true);
while (MYSQL_ROW row = mysql_fetch_row(result))
{
char query[64];
if (row[1] && !strcmp(row[1], "Killed"))
continue;
msg_ts("Killing MDL waiting %s ('%s') on connection %s\n",
row[1], row[2], row[0]);
snprintf(query, sizeof(query), "KILL QUERY %s", row[0]);
if (mysql_query(mysql, query) && (mysql_errno(mysql) != ER_NO_SUCH_THREAD)) {
msg("Error: failed to execute query %s: %s\n", query,mysql_error(mysql));
exit(EXIT_FAILURE);
}
}
mysql_free_result(result);
}
mysql_close(mysql);
stop_thread:
msg_ts("Kill mdl waiters thread stopped\n");
os_event_set(mdl_killer_finished_event);
os_thread_exit();
return os_thread_ret_t(0);
}
static void start_mdl_waiters_killer()
{
mdl_killer_stop_event = os_event_create(0);
mdl_killer_finished_event = os_event_create(0);
os_thread_create(kill_mdl_waiters_thread, 0, 0);
}
/* Tell MDL killer to stop and finish for its completion*/
static void stop_mdl_waiters_killer()
{
os_event_set(mdl_killer_stop_event);
os_event_wait(mdl_killer_finished_event);
os_event_destroy(mdl_killer_stop_event);
os_event_destroy(mdl_killer_finished_event);
}
/*********************************************************************//**
Function acquires either a backup tables lock, if supported
by the server, or a global read lock (FLUSH TABLES WITH READ LOCK)
......@@ -970,12 +893,6 @@ lock_tables(MYSQL *connection)
return(true);
}
if (opt_lock_ddl_per_table) {
/* TODO : Remove after MDEV-17772 is fixed */
start_mdl_waiters_killer();
}
if (opt_lock_wait_timeout) {
if (!wait_for_no_updates(connection, opt_lock_wait_timeout,
opt_lock_wait_threshold)) {
......@@ -999,11 +916,6 @@ lock_tables(MYSQL *connection)
//xb_mysql_query(connection, "BACKUP STAGE BLOCK_DDL", true);
xb_mysql_query(connection, "BACKUP STAGE BLOCK_COMMIT", true);
if (opt_lock_ddl_per_table) {
/* TODO : Remove after MDEV-17772 is fixed */
stop_mdl_waiters_killer();
}
if (opt_kill_long_queries_timeout) {
stop_query_killer();
}
......
......@@ -4245,7 +4245,7 @@ xtrabackup_backup_func()
DBUG_EXECUTE_IF("check_mdl_lock_works",
dbug_alter_thread_done =
dbug_start_query_thread("ALTER TABLE test.t ADD COLUMN mdl_lock_column int",
"Waiting for table metadata lock", 1, ER_QUERY_INTERRUPTED););
"Waiting for table metadata lock", 0, 0););
}
datafiles_iter_t *it = datafiles_iter_new();
......@@ -4463,6 +4463,7 @@ void backup_fix_ddl(void)
}
datafiles_iter_free(it);
DBUG_EXECUTE_IF("check_mdl_lock_works", DBUG_ASSERT(new_tables.size() == 0););
for (std::set<std::string>::iterator iter = new_tables.begin();
iter != new_tables.end(); iter++) {
const char *space_name = iter->c_str();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment