diff --git a/storage/innobase/xtrabackup/src/backup_mysql.cc b/storage/innobase/xtrabackup/src/backup_mysql.cc index 0961baa1402..f7b0dc4b022 100644 --- a/storage/innobase/xtrabackup/src/backup_mysql.cc +++ b/storage/innobase/xtrabackup/src/backup_mysql.cc @@ -1139,6 +1139,12 @@ bool lock_tables_maybe(MYSQL *connection, int timeout, int retry_count) { bool force_ftwrl = opt_slave_info && !slave_auto_position && !(server_flavor == FLAVOR_PERCONA_SERVER); + /** If it's XCluster, always use FTWRL, because commit index (for leader), + apply index (for follower) can not get from p_s.log_status. */ + if (server_flavor == FLAVOR_X_CLUSTER) { + force_ftwrl = true; + } + if (tables_locked || (opt_lock_ddl_per_table && !force_ftwrl)) { return (true); } @@ -1147,8 +1153,6 @@ bool lock_tables_maybe(MYSQL *connection, int timeout, int retry_count) { return (true); } - disable_replication_for_polarx(connection); - if (have_backup_locks && !force_ftwrl) { return lock_tables_for_backup(connection, timeout, retry_count); } @@ -1172,8 +1176,6 @@ void unlock_all(MYSQL *connection) { } xb::info() << "All tables unlocked"; - - enable_replication_for_polarx(connection); } static int get_open_temp_tables(MYSQL *connection) { @@ -2628,32 +2630,3 @@ bool print_instant_versioned_tables(MYSQL *connection) { return ret; } -void disable_replication_for_polarx(MYSQL *connection) { - if (xcluster_sql_thread_started) return; - - if (server_flavor == FLAVOR_X_CLUSTER) { - // if slave_sql_running, stop mts - char *slave_sql_running = NULL; - mysql_variable status[] = {{"Slave_SQL_Running", &slave_sql_running}, - {NULL, NULL}}; - read_mysql_variables(connection, "SHOW SLAVE STATUS", status, false); - if (strcmp(slave_sql_running, "Yes") == 0) { - xb::info() << "Disable replication for polarx..."; - xcluster_sql_thread_started = true; - xb_mysql_query(connection, "STOP SLAVE SQL_THREAD", false, false); - xb_mysql_query(connection, "STOP XPAXOS_REPLICATION", false, false); - } - free_mysql_variables(status); - } -} - -void enable_replication_for_polarx(MYSQL *connection) { - if (!xcluster_sql_thread_started) return; - - if (server_flavor == FLAVOR_X_CLUSTER) { - xb::info() << "Enable replication for polarx..."; - xb_mysql_query(connection, "START SLAVE SQL_THREAD", false, false); - xb_mysql_query(connection, "START XPAXOS_REPLICATION", false, false); - xcluster_sql_thread_started = false; - } -} diff --git a/storage/innobase/xtrabackup/src/backup_mysql.h b/storage/innobase/xtrabackup/src/backup_mysql.h index 102813c2aa1..ac5249b7463 100644 --- a/storage/innobase/xtrabackup/src/backup_mysql.h +++ b/storage/innobase/xtrabackup/src/backup_mysql.h @@ -278,8 +278,4 @@ void check_dump_innodb_buffer_pool(MYSQL *connection); bool print_instant_versioned_tables(MYSQL *connection); extern log_status_t log_status; -void disable_replication_for_polarx(MYSQL *connection); - -void enable_replication_for_polarx(MYSQL *connection); - #endif diff --git a/storage/innobase/xtrabackup/src/xtrabackup.cc b/storage/innobase/xtrabackup/src/xtrabackup.cc index a401f03da97..06061a28e13 100644 --- a/storage/innobase/xtrabackup/src/xtrabackup.cc +++ b/storage/innobase/xtrabackup/src/xtrabackup.cc @@ -7660,7 +7660,6 @@ bool xb_init() { } if (opt_lock_ddl) { - disable_replication_for_polarx(mysql_connection); if (!lock_tables_for_backup(mysql_connection, opt_lock_ddl_timeout, 0)) return (false); }