diff options
Diffstat (limited to 'extra/mariabackup/backup_mysql.cc')
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 120 |
1 files changed, 7 insertions, 113 deletions
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 831433b43e2..b0ee0420049 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -861,82 +861,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"); - 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("Killing MDL waiting %s ('%s') on connection %s", - 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)) { - die("failed to execute query %s: %s", query,mysql_error(mysql)); - } - } - mysql_free_result(result); - } - - mysql_close(mysql); - -stop_thread: - msg("Kill mdl waiters thread stopped"); - 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) @@ -959,30 +883,6 @@ lock_tables(MYSQL *connection) return(true); } - if (opt_lock_ddl_per_table) { - start_mdl_waiters_killer(); - } - - if (!opt_lock_wait_timeout && !opt_kill_long_queries_timeout) { - - /* We do first a FLUSH TABLES. If a long update is running, the - FLUSH TABLES will wait but will not stall the whole mysqld, and - when the long update is done the FLUSH TABLES WITH READ LOCK - will start and succeed quickly. So, FLUSH TABLES is to lower - the probability of a stage where both mysqldump and most client - connections are stalled. Of course, if a second long update - starts between the two FLUSHes, we have that bad stall. - - Option lock_wait_timeout serve the same purpose and is not - compatible with this trick. - */ - - msg("Executing FLUSH NO_WRITE_TO_BINLOG TABLES..."); - - xb_mysql_query(connection, - "FLUSH NO_WRITE_TO_BINLOG TABLES", false); - } - if (opt_lock_wait_timeout) { if (!wait_for_no_updates(connection, opt_lock_wait_timeout, opt_lock_wait_threshold)) { @@ -990,7 +890,7 @@ lock_tables(MYSQL *connection) } } - msg("Executing FLUSH TABLES WITH READ LOCK..."); + msg("Acquiring BACKUP LOCKS..."); if (opt_kill_long_queries_timeout) { start_query_killer(); @@ -1001,11 +901,10 @@ lock_tables(MYSQL *connection) "SET SESSION wsrep_causal_reads=0", false); } - xb_mysql_query(connection, "FLUSH TABLES WITH READ LOCK", false); - - if (opt_lock_ddl_per_table) { - stop_mdl_waiters_killer(); - } + xb_mysql_query(connection, "BACKUP STAGE START", true); + //xb_mysql_query(connection, "BACKUP STAGE FLUSH", true); + //xb_mysql_query(connection, "BACKUP STAGE BLOCK_DDL", true); + xb_mysql_query(connection, "BACKUP STAGE BLOCK_COMMIT", true); if (opt_kill_long_queries_timeout) { stop_query_killer(); @@ -1047,13 +946,8 @@ unlock_all(MYSQL *connection) os_thread_sleep(opt_debug_sleep_before_unlock * 1000); } - if (binlog_locked) { - msg("Executing UNLOCK BINLOG"); - xb_mysql_query(connection, "UNLOCK BINLOG", false); - } - - msg("Executing UNLOCK TABLES"); - xb_mysql_query(connection, "UNLOCK TABLES", false); + msg("Executing BACKUP STAGE END"); + xb_mysql_query(connection, "BACKUP STAGE END", false); msg("All tables unlocked"); } |