diff options
author | unknown <knielsen@knielsen-hq.org> | 2013-04-04 17:38:10 +0200 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2013-04-04 17:38:10 +0200 |
commit | c2cbc9cee6a3f8f745501ee2f5fcfd4586f53bbd (patch) | |
tree | b779d3a554d9f69556e1a805b46bf27261a5c451 /sql | |
parent | bdf6367d0e019703b48c62b1ae5728e48ba0eba7 (diff) | |
download | mariadb-git-c2cbc9cee6a3f8f745501ee2f5fcfd4586f53bbd.tar.gz |
MDEV-26: Global transaction ID.
Move combining slave and gtid binlog state into a separate function.
Make SHOW ALL SLAVES STATUS use the same function, so it shows the
same value used by slave connect.
Add a test case.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/slave.cc | 36 | ||||
-rw-r--r-- | sql/sql_repl.cc | 26 | ||||
-rw-r--r-- | sql/sql_repl.h | 1 |
3 files changed, 42 insertions, 21 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index f373c8b2c45..a2f97e8a1e9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1820,8 +1820,6 @@ after_set_capability: char str_buf[256]; String connect_state(str_buf, sizeof(str_buf), system_charset_info); connect_state.length(0); - rpl_gtid *binlog_gtid_list= NULL; - uint32 num_binlog_gtids= 0; /* Read the master @@GLOBAL.gtid_domain_id variable. @@ -1844,27 +1842,18 @@ after_set_capability: mysql_free_result(master_res); master_res= NULL; - if (opt_bin_log) - { - int err= mysql_bin_log.get_most_recent_gtid_list(&binlog_gtid_list, - &num_binlog_gtids); - if (err) - { - err_code= ER_OUTOFMEMORY; - errmsg= "The slave I/O thread stops because a fatal out-of-memory " - "error is encountered when it tries to compute @slave_connect_state."; - sprintf(err_buff, "%s Error: Out of memory", errmsg); - goto err; - } - } - connect_state.append(STRING_WITH_LEN("SET @slave_connect_state='"), system_charset_info); - rpl_global_gtid_slave_state.tostring(&connect_state, binlog_gtid_list, - num_binlog_gtids); - if (binlog_gtid_list) - my_free(binlog_gtid_list); + if (rpl_append_gtid_state(&connect_state, true)) + { + err_code= ER_OUTOFMEMORY; + errmsg= "The slave I/O thread stops because a fatal out-of-memory " + "error is encountered when it tries to compute @slave_connect_state."; + sprintf(err_buff, "%s Error: Out of memory", errmsg); + goto err; + } connect_state.append(STRING_WITH_LEN("'"), system_charset_info); + rc= mysql_real_query(mysql, connect_state.ptr(), connect_state.length()); if (rc) { @@ -2511,7 +2500,12 @@ bool show_all_master_info(THD* thd) DBUG_ENTER("show_master_info"); mysql_mutex_assert_owner(&LOCK_active_mi); - rpl_global_gtid_slave_state.tostring(>id_pos, NULL, 0); + gtid_pos.length(0); + if (rpl_append_gtid_state(>id_pos, true)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + DBUG_RETURN(TRUE); + } if (send_show_master_info_header(thd, 1, gtid_pos.length())) DBUG_RETURN(TRUE); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 0f8dbdd5112..ad5e5f64dad 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -3360,4 +3360,30 @@ rpl_deinit_gtid_slave_state() rpl_global_gtid_slave_state.deinit(); } + +/* + Format the current GTID state as a string, for use when connecting to a + master server with GTID, or for returning the value of @@global.gtid_state. + + If the flag use_binlog is true, then the contents of the binary log (if + enabled) is merged into the current GTID state. +*/ +int +rpl_append_gtid_state(String *dest, bool use_binlog) +{ + int err; + rpl_gtid *gtid_list= NULL; + uint32 num_gtids= 0; + + if (opt_bin_log && + (err= mysql_bin_log.get_most_recent_gtid_list(>id_list, &num_gtids))) + return err; + + rpl_global_gtid_slave_state.tostring(dest, gtid_list, num_gtids); + my_free(gtid_list); + + return 0; +} + + #endif /* HAVE_REPLICATION */ diff --git a/sql/sql_repl.h b/sql/sql_repl.h index dd67aaa12f8..22183f2a2b2 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -69,6 +69,7 @@ extern PSI_mutex_key key_LOCK_slave_state, key_LOCK_binlog_state; void rpl_init_gtid_slave_state(); void rpl_deinit_gtid_slave_state(); int gtid_state_from_binlog_pos(const char *name, uint32 pos, String *out_str); +int rpl_append_gtid_state(String *dest, bool use_binlog); #endif /* HAVE_REPLICATION */ |