mirror of
https://github.com/MariaDB/server.git
synced 2025-08-05 13:16:09 +03:00
MDEV-6490: mysqldump unknown option --galera-sst-mode
A new command line option "galera-sst-mode" was introduced in mysqldump as part of fix for MDEV-6316. But, since the fix was pushed to maria-10.0-galera branch, the mysqldump tool supplied with mariadb client deb/rpm packages, does not have this new opion. This fix contains the same patch along with a test case.
This commit is contained in:
@@ -93,6 +93,7 @@ enum options_client
|
|||||||
OPT_SKIP_ANNOTATE_ROWS_EVENTS,
|
OPT_SKIP_ANNOTATE_ROWS_EVENTS,
|
||||||
OPT_SSL_CRL, OPT_SSL_CRLPATH,
|
OPT_SSL_CRL, OPT_SSL_CRLPATH,
|
||||||
OPT_USE_GTID,
|
OPT_USE_GTID,
|
||||||
|
OPT_GALERA_SST_MODE,
|
||||||
OPT_MAX_CLIENT_OPTION /* should be always the last */
|
OPT_MAX_CLIENT_OPTION /* should be always the last */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -114,6 +114,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
|
|||||||
opt_slave_apply= 0,
|
opt_slave_apply= 0,
|
||||||
opt_include_master_host_port= 0,
|
opt_include_master_host_port= 0,
|
||||||
opt_events= 0, opt_comments_used= 0,
|
opt_events= 0, opt_comments_used= 0,
|
||||||
|
opt_galera_sst_mode= 0,
|
||||||
opt_alltspcs=0, opt_notspcs= 0;
|
opt_alltspcs=0, opt_notspcs= 0;
|
||||||
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 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;
|
static ulong opt_max_allowed_packet, opt_net_buffer_length;
|
||||||
@@ -350,6 +351,14 @@ static struct my_option my_long_options[] =
|
|||||||
{"force", 'f', "Continue even if we get an SQL error.",
|
{"force", 'f', "Continue even if we get an SQL error.",
|
||||||
&ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG,
|
&ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG,
|
||||||
0, 0, 0, 0, 0, 0},
|
0, 0, 0, 0, 0, 0},
|
||||||
|
{"galera-sst-mode", OPT_GALERA_SST_MODE,
|
||||||
|
"This mode should normally be used in mysqldump snapshot state transfer "
|
||||||
|
"(SST) in a Galera cluster. If enabled, mysqldump additionally dumps "
|
||||||
|
"commands to turn off binary logging and SET global gtid_binlog_state "
|
||||||
|
"with the current value. Note: RESET MASTER needs to be executed on the "
|
||||||
|
"server receiving the resulting dump.",
|
||||||
|
&opt_galera_sst_mode, &opt_galera_sst_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||||
|
0, 0, 0},
|
||||||
{"gtid", OPT_USE_GTID, "Used together with --master-data=1 or --dump-slave=1."
|
{"gtid", OPT_USE_GTID, "Used together with --master-data=1 or --dump-slave=1."
|
||||||
"When enabled, the output from those options will set the GTID position "
|
"When enabled, the output from those options will set the GTID position "
|
||||||
"instead of the binlog file and offset; the file/offset will appear only as "
|
"instead of the binlog file and offset; the file/offset will appear only as "
|
||||||
@@ -4894,6 +4903,43 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
|
|||||||
} /* dump_selected_tables */
|
} /* dump_selected_tables */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Add the following statements to the generated dump:
|
||||||
|
a) SET @@session.sql_log_bin=OFF;
|
||||||
|
b) SET @@global.gtid_binlog_state='[N-N-N,...]'
|
||||||
|
*/
|
||||||
|
static int wsrep_set_sst_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
|
static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
|
||||||
int have_mariadb_gtid, int use_gtid)
|
int have_mariadb_gtid, int use_gtid)
|
||||||
{
|
{
|
||||||
@@ -5889,6 +5935,10 @@ int main(int argc, char **argv)
|
|||||||
/* Add 'STOP SLAVE to beginning of dump */
|
/* Add 'STOP SLAVE to beginning of dump */
|
||||||
if (opt_slave_apply && add_stop_slave())
|
if (opt_slave_apply && add_stop_slave())
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
if (opt_galera_sst_mode && wsrep_set_sst_cmds(mysql))
|
||||||
|
goto err;
|
||||||
|
|
||||||
if (opt_master_data && do_show_master_status(mysql, consistent_binlog_pos,
|
if (opt_master_data && do_show_master_status(mysql, consistent_binlog_pos,
|
||||||
have_mariadb_gtid, opt_use_gtid))
|
have_mariadb_gtid, opt_use_gtid))
|
||||||
goto err;
|
goto err;
|
||||||
|
32
mysql-test/r/galera_sst_mode.result
Normal file
32
mysql-test/r/galera_sst_mode.result
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#
|
||||||
|
# Test for mysqldump's galera-sst-mode option
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MDEV-6490: mysqldump unknown option --galera-sst-mode
|
||||||
|
#
|
||||||
|
CREATE DATABASE bug6490;
|
||||||
|
USE bug6490;
|
||||||
|
CREATE TABLE t1(c1 INT);
|
||||||
|
INSERT INTO t1 values (1);
|
||||||
|
INSERT INTO t1 values (2);
|
||||||
|
# @@global.gtid_binlog_state - after
|
||||||
|
SELECT @@global.gtid_binlog_state;
|
||||||
|
@@global.gtid_binlog_state
|
||||||
|
0-1-4
|
||||||
|
# Save the current gtid_binlog_state.
|
||||||
|
# Take a dump of bug6490 database
|
||||||
|
DROP TABLE t1;
|
||||||
|
# Load the dump
|
||||||
|
RESET MASTER;
|
||||||
|
SELECT * from t1;
|
||||||
|
c1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
# @@global.gtid_binlog_state - after
|
||||||
|
SELECT @@global.gtid_binlog_state;
|
||||||
|
@@global.gtid_binlog_state
|
||||||
|
0-1-4
|
||||||
|
# Compare the two gtid_binlog_state's
|
||||||
|
# Cleanup
|
||||||
|
DROP DATABASE bug6490;
|
||||||
|
# End of test
|
49
mysql-test/t/galera_sst_mode.test
Normal file
49
mysql-test/t/galera_sst_mode.test
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Embedded server doesn't support external clients
|
||||||
|
--source include/not_embedded.inc
|
||||||
|
# Binlog is required
|
||||||
|
--source include/have_log_bin.inc
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Test for mysqldump's galera-sst-mode option
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-6490: mysqldump unknown option --galera-sst-mode
|
||||||
|
--echo #
|
||||||
|
CREATE DATABASE bug6490;
|
||||||
|
USE bug6490;
|
||||||
|
CREATE TABLE t1(c1 INT);
|
||||||
|
INSERT INTO t1 values (1);
|
||||||
|
INSERT INTO t1 values (2);
|
||||||
|
|
||||||
|
--echo # @@global.gtid_binlog_state - after
|
||||||
|
SELECT @@global.gtid_binlog_state;
|
||||||
|
|
||||||
|
--echo # Save the current gtid_binlog_state.
|
||||||
|
--let $before= `SELECT @@global.gtid_binlog_state`
|
||||||
|
|
||||||
|
--echo # Take a dump of bug6490 database
|
||||||
|
--exec $MYSQL_DUMP --galera-sst-mode bug6490 > $MYSQLTEST_VARDIR/tmp/bug6490.sql
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo # Load the dump
|
||||||
|
RESET MASTER;
|
||||||
|
--exec $MYSQL -uroot bug6490 < $MYSQLTEST_VARDIR/tmp/bug6490.sql
|
||||||
|
|
||||||
|
SELECT * from t1;
|
||||||
|
|
||||||
|
--echo # @@global.gtid_binlog_state - after
|
||||||
|
SELECT @@global.gtid_binlog_state;
|
||||||
|
|
||||||
|
--echo # Compare the two gtid_binlog_state's
|
||||||
|
--let $after= `SELECT @@global.gtid_binlog_state`
|
||||||
|
if (`SELECT STRCMP($before, $after)`)
|
||||||
|
{
|
||||||
|
--die ERROR: The two gtid_binlog_state's did not match.
|
||||||
|
}
|
||||||
|
|
||||||
|
--echo # Cleanup
|
||||||
|
--remove_file $MYSQLTEST_VARDIR/tmp/bug6490.sql
|
||||||
|
DROP DATABASE bug6490;
|
||||||
|
|
||||||
|
--echo # End of test
|
Reference in New Issue
Block a user