diff options
author | Jan Lindström <jan.lindstrom@skysql.com> | 2014-08-27 13:15:37 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@skysql.com> | 2014-08-27 13:15:37 +0300 |
commit | ab150128ce78fd363f6041277862686a61730b2b (patch) | |
tree | 1e1a04cc057f5d52eb223266623f32d805444a87 /client | |
parent | 9534fd83ce6dc402132cc304c121c9205b430dda (diff) | |
parent | 20e20f6db6fe7f752cccdb34c1ac1d54c2f30cec (diff) | |
download | mariadb-git-ab150128ce78fd363f6041277862686a61730b2b.tar.gz |
MDEV-6247: Merge 10.0-galera to 10.1.
Merged lp:maria/maria-10.0-galera up to revision 3880.
Added a new functions to handler API to forcefully abort_transaction,
producing fake_trx_id, get_checkpoint and set_checkpoint for XA. These
were added for future possiblity to add more storage engines that
could use galera replication.
Diffstat (limited to 'client')
-rw-r--r-- | client/client_priv.h | 1 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 5 | ||||
-rw-r--r-- | client/mysqlcheck.c | 6 | ||||
-rw-r--r-- | client/mysqldump.c | 49 |
4 files changed, 61 insertions, 0 deletions
diff --git a/client/client_priv.h b/client/client_priv.h index 656c8fcf32a..ef93818829e 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -92,6 +92,7 @@ enum options_client OPT_REPORT_PROGRESS, OPT_SKIP_ANNOTATE_ROWS_EVENTS, OPT_SSL_CRL, OPT_SSL_CRLPATH, + OPT_GALERA_SST_MODE, OPT_MAX_CLIENT_OPTION /* should be always the last */ }; diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 80d57ce9faa..bf33397efdb 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -523,7 +523,12 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, int ret; File fd; char query_file_path[FN_REFLEN]; +#ifdef WITH_WSREP + /* Note: wsrep_on=ON implicitly enables binary logging. */ + const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0, WSREP_ON=OFF;"; +#else const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0;"; +#endif /* WITH_WSREP */ DBUG_ENTER("run_query"); DBUG_PRINT("enter", ("query: %s", query)); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 57b7ce09ab5..f7ae0783e5e 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -731,9 +731,15 @@ static int use_db(char *database) DBUG_RETURN(0); } /* use_db */ +/* Do not send commands to replication slaves. */ static int disable_binlog() { +#ifdef WITH_WSREP + /* Additionally turn off @@wsrep_on to disable implicit binary logging. */ + const char *stmt= "SET SQL_LOG_BIN=0, WSREP_ON=OFF"; +#else const char *stmt= "SET SQL_LOG_BIN=0"; +#endif /* WITH_WSREP */ return run_query(stmt); } diff --git a/client/mysqldump.c b/client/mysqldump.c index db2813158b0..b8d04014552 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -111,6 +111,7 @@ 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, + opt_galera_sst_mode= 0, opt_alltspcs=0, opt_notspcs= 0, opt_logging; 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 +347,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}, + {"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}, {"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, " @@ -4805,6 +4814,42 @@ static int dump_selected_tables(char *db, char **table_names, int 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) { MYSQL_ROW row; @@ -5749,6 +5794,10 @@ int main(int argc, char **argv) /* Add 'STOP SLAVE to beginning of dump */ if (opt_slave_apply && add_stop_slave()) 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)) goto err; if (opt_slave_data && do_show_slave_status(mysql)) |