diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-04-06 10:30:49 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-04-06 10:30:49 +0300 |
commit | 5d8dcfd86c5eb8c588ecf17519884dffcf8b0818 (patch) | |
tree | 90d716dcfcc9d7462064584546dcf52192dce8e2 /sql/wsrep_sst.cc | |
parent | cacb61b6be78b01a9c62890cc81d059ee46921ac (diff) | |
parent | cbdf62ae907ad42ceb7a65e070b821bb45e07be9 (diff) | |
download | mariadb-git-5d8dcfd86c5eb8c588ecf17519884dffcf8b0818.tar.gz |
MDEV-25975: Merge 10.4 into 10.5
Diffstat (limited to 'sql/wsrep_sst.cc')
-rw-r--r-- | sql/wsrep_sst.cc | 85 |
1 files changed, 25 insertions, 60 deletions
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index e08ece56877..4a1ae85f4cc 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -1,4 +1,5 @@ /* Copyright 2008-2022 Codership Oy <http://www.codership.com> + Copyright (c) 2008, 2022, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1496,47 +1497,18 @@ static int run_sql_command(THD *thd, const char *query) } mysql_parse(thd, thd->query(), thd->query_length(), &ps, FALSE, FALSE); + if (thd->is_error()) { int const err= thd->get_stmt_da()->sql_errno(); - WSREP_WARN ("Error executing '%s': %d (%s)%s", - query, err, thd->get_stmt_da()->message(), - err == ER_UNKNOWN_SYSTEM_VARIABLE ? - ". Was mysqld built with --with-innodb-disallow-writes ?" : ""); + WSREP_WARN ("Error executing '%s': %d (%s)", + query, err, thd->get_stmt_da()->message()); thd->clear_error(); return -1; } return 0; } -static void sst_disallow_writes (THD* thd, bool yes) -{ - char query_str[64]= { 0, }; - ssize_t const query_max= sizeof(query_str) - 1; - CHARSET_INFO *current_charset; - - current_charset= thd->variables.character_set_client; - - if (!is_supported_parser_charset(current_charset)) - { - /* Do not use non-supported parser character sets */ - WSREP_WARN("Current client character set is non-supported parser character set: %s", current_charset->csname); - thd->variables.character_set_client= &my_charset_latin1; - WSREP_WARN("For SST temporally setting character set to : %s", - my_charset_latin1.csname); - } - - snprintf (query_str, query_max, "SET GLOBAL innodb_disallow_writes=%d", - yes ? 1 : 0); - - if (run_sql_command(thd, query_str)) - { - WSREP_ERROR("Failed to disallow InnoDB writes"); - } - thd->variables.character_set_client= current_charset; -} - - static int sst_flush_tables(THD* thd) { WSREP_INFO("Flushing tables for SST..."); @@ -1596,16 +1568,11 @@ static int sst_flush_tables(THD* thd) } else { - WSREP_INFO("Tables flushed."); + ha_disable_internal_writes(true); - /* disable further disk IO */ - sst_disallow_writes(thd, true); - WSREP_INFO("Disabled further disk IO."); + WSREP_INFO("Tables flushed."); - /* - Tables have been flushed. Create a file with cluster state ID and - wsrep_gtid_domain_id. - */ + // Create a file with cluster state ID and wsrep_gtid_domain_id. char content[100]; snprintf(content, sizeof(content), "%s:%lld %d\n", wsrep_cluster_state_uuid, (long long)wsrep_locked_seqno, wsrep_gtid_server.domain_id); @@ -1648,6 +1615,8 @@ static int sst_flush_tables(THD* thd) } free(real_name); free(tmp_name); + if (err) + ha_disable_internal_writes(false); } return err; @@ -1698,31 +1667,30 @@ wait_signal: if (!strcasecmp (out, magic_flush)) { err= sst_flush_tables (thd.ptr); + if (!err) { - /* + locked= true; + /* Lets also keep statements that modify binary logs (like RESET LOGS, RESET MASTER) from proceeding until the files have been transferred to the joiner node. */ if (mysql_bin_log.is_open()) - { mysql_mutex_lock(mysql_bin_log.get_log_lock()); - } - - locked= true; - WSREP_INFO("Donor state reached"); + WSREP_INFO("Donor state reached"); DBUG_EXECUTE_IF("sync.wsrep_donor_state", - { - const char act[]= - "now " - "SIGNAL sync.wsrep_donor_state_reached " - "WAIT_FOR signal.wsrep_donor_state"; - assert(!debug_sync_set_action(thd.ptr, - STRING_WITH_LEN(act))); - };); + { + const char act[]= + "now " + "SIGNAL sync.wsrep_donor_state_reached " + "WAIT_FOR signal.wsrep_donor_state"; + assert(!debug_sync_set_action(thd.ptr, + STRING_WITH_LEN(act))); + };); + goto wait_signal; } } @@ -1730,14 +1698,11 @@ wait_signal: { if (locked) { + locked= false; + ha_disable_internal_writes(false); if (mysql_bin_log.is_open()) - { - mysql_mutex_assert_owner(mysql_bin_log.get_log_lock()); mysql_mutex_unlock(mysql_bin_log.get_log_lock()); - } - sst_disallow_writes (thd.ptr, false); thd.ptr->global_read_lock.unlock_global_read_lock(thd.ptr); - locked= false; } err= 0; goto wait_signal; @@ -1768,12 +1733,12 @@ wait_signal: if (locked) // don't forget to unlock server before return { + ha_disable_internal_writes(false); if (mysql_bin_log.is_open()) { mysql_mutex_assert_owner(mysql_bin_log.get_log_lock()); mysql_mutex_unlock(mysql_bin_log.get_log_lock()); } - sst_disallow_writes (thd.ptr, false); thd.ptr->global_read_lock.unlock_global_read_lock(thd.ptr); } |