summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/client_priv.h3
-rw-r--r--client/mysqldump.c55
-rw-r--r--scripts/wsrep_sst_mysqldump.sh7
3 files changed, 64 insertions, 1 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))
diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh
index 3fce316f379..a8ed19c5381 100644
--- a/scripts/wsrep_sst_mysqldump.sh
+++ b/scripts/wsrep_sst_mysqldump.sh
@@ -79,7 +79,7 @@ STOP_WSREP="SET wsrep_on=OFF;"
MYSQLDUMP="mysqldump $AUTH -S$WSREP_SST_OPT_SOCKET \
--add-drop-database --add-drop-table --skip-add-locks --create-options \
--disable-keys --extended-insert --skip-lock-tables --quick --set-charset \
---skip-comments --flush-privileges --all-databases"
+--skip-comments --flush-privileges --all-databases --galera-sst-mode"
# mysqldump cannot restore CSV tables, fix this issue
CSV_TABLES_FIX="
@@ -118,8 +118,13 @@ $MYSQL -e"$STOP_WSREP SET GLOBAL SLOW_QUERY_LOG=OFF"
RESTORE_GENERAL_LOG="SET GLOBAL GENERAL_LOG=$GENERAL_LOG_OPT;"
RESTORE_SLOW_QUERY_LOG="SET GLOBAL SLOW_QUERY_LOG=$SLOW_LOG_OPT;"
+# reset master for 10.0 to clear gtid state
+RESET_MASTER="RESET MASTER;"
+
+
if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
then
+ (echo $STOP_WSREP && echo $RESET_MASTER) | $MYSQL || true
(echo $STOP_WSREP && $MYSQLDUMP && echo $CSV_TABLES_FIX \
&& echo $RESTORE_GENERAL_LOG && echo $RESTORE_SLOW_QUERY_LOG \
&& echo $SET_START_POSITION \