diff options
author | Nirbhay Choubey <nirbhay@skysql.com> | 2014-06-16 14:55:14 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@skysql.com> | 2014-06-16 14:55:14 -0400 |
commit | 1fbb70559b45fee8be142e44249e8fc81b8ee3a8 (patch) | |
tree | 8fed89ea6331c1d44908f5673d4b3fa662c0253d /client | |
parent | 20279b0473b959172a3bffe14940f6708dabad30 (diff) | |
download | mariadb-git-1fbb70559b45fee8be142e44249e8fc81b8ee3a8.tar.gz |
MDEV#6316: Fix mysqldump SST method to transfer binlog
state to the joiner
In mysqldump SST, if Galera nodes are started with --log-bin and
-log-slave-updates, the GTID sequence increases as the dump is
played on the joiner, leaving behind the donor.
This patch introduces a new mysqldump option --galera-sst-mode,
which if enabled, would
a) Add command to set off binary logging (log_bin=OFF).
b) Add command to set @@global.gtid_binlog_state to that
of donor.
This will help in keeping the GTIDs consistent post-SST across
the nodes.
Diffstat (limited to 'client')
-rw-r--r-- | client/client_priv.h | 3 | ||||
-rw-r--r-- | client/mysqldump.c | 55 |
2 files changed, 58 insertions, 0 deletions
diff --git a/client/client_priv.h b/client/client_priv.h index 656c8fcf32a..dddf934e509 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -92,6 +92,9 @@ enum options_client OPT_REPORT_PROGRESS, OPT_SKIP_ANNOTATE_ROWS_EVENTS, OPT_SSL_CRL, OPT_SSL_CRLPATH, +#ifdef WITH_WSREP + OPT_GALERA_SST_MODE, +#endif OPT_MAX_CLIENT_OPTION /* should be always the last */ }; diff --git a/client/mysqldump.c b/client/mysqldump.c index cb4fa022d4f..5963d4da460 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -111,6 +111,9 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_slave_apply= 0, opt_include_master_host_port= 0, opt_events= 0, opt_comments_used= 0, +#ifdef WITH_WSREP + opt_galera_sst_mode= 0, +#endif opt_alltspcs=0, opt_notspcs= 0; static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; @@ -346,6 +349,14 @@ static struct my_option my_long_options[] = {"force", 'f', "Continue even if we get an SQL error.", &ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, +#ifdef WITH_WSREP + {"galera-sst-mode", OPT_GALERA_SST_MODE, "This mode is normally used " + "in mysqldump snapshot-state transfer in a Galera cluster. If enabled, " + "mysqldump additionally emits statements to turn off binary logging and " + "set global gtid_binlog_state with the current value.", + &opt_galera_sst_mode, &opt_galera_sst_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, + 0, 0, 0}, +#endif {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"hex-blob", OPT_HEXBLOB, "Dump binary strings (BINARY, " @@ -4799,6 +4810,44 @@ static int dump_selected_tables(char *db, char **table_names, int tables) } /* dump_selected_tables */ +#ifdef WITH_WSREP +/** + Additionally emit the following statements : + a) SET @@session.sql_log_bin=OFF; + b) SET @@global.gtid_binlog_state='[N-N-N,...]' +*/ +static int wsrep_add_sst_mode_cmds(MYSQL *mysql) { + MYSQL_RES *res; + MYSQL_ROW row; + + if (mysql_get_server_version(mysql) < 100005) { + // @@gtid_binlog_state does not exist. + return 0; + } + + if (mysql_query_with_error_report(mysql, &res, "SELECT " + "@@global.gtid_binlog_state")) + return 1; + + if (mysql_num_rows(res) != 1) + // No entry for @@global.gtid_binlog_state, nothing needs to be done. + return 0; + + if (!(row= mysql_fetch_row(res)) || !(char *)row[0]) + return 1; + + // first, add a command to turn off binary logging, + fprintf(md_result_file, "SET @@session.sql_log_bin=OFF;\n"); + + // followed by, a command to set global gtid_binlog_state. + fprintf(md_result_file, "SET @@global.gtid_binlog_state='%s';\n", + (char*)row[0]); + + mysql_free_result(res); + return 0; +} +#endif + static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos) { MYSQL_ROW row; @@ -5743,6 +5792,12 @@ int main(int argc, char **argv) /* Add 'STOP SLAVE to beginning of dump */ if (opt_slave_apply && add_stop_slave()) goto err; + +#ifdef WITH_WSREP + if (opt_galera_sst_mode && wsrep_add_sst_mode_cmds(mysql)) + goto err; +#endif + if (opt_master_data && do_show_master_status(mysql, consistent_binlog_pos)) goto err; if (opt_slave_data && do_show_slave_status(mysql)) |