diff options
author | unknown <knielsen@knielsen-hq.org> | 2013-06-03 07:41:38 +0200 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2013-06-03 07:41:38 +0200 |
commit | 7ad47ab0e080ca66f8a41de461b036d3bdff25fb (patch) | |
tree | 2f66464864677488b7b882522e50cb2aea58a4f4 /sql/sys_vars.cc | |
parent | 6feadb10823c352b1eb9b24682c7d24d32175b0f (diff) | |
download | mariadb-git-7ad47ab0e080ca66f8a41de461b036d3bdff25fb.tar.gz |
MDEV-4605: Failing to load GTID slave position from rpl.gtid_slave_pos
There were several cases where the slave GTID position was not loaded
correctly before being used. This caused various failures such as
corrupting the position at slave start and empty values of
@@gtid_slave_pos and @@gtid_current_pos.
Fixed by adding more checks for loaded position, and by always loading
the position at server startup.
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r-- | sql/sys_vars.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 75d11589be6..b25f979cf79 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1262,6 +1262,12 @@ Sys_var_gtid_binlog_pos::global_value_ptr(THD *thd, LEX_STRING *base) String str(buf, sizeof(buf), system_charset_info); char *p; + if (!rpl_global_gtid_slave_state.loaded) + { + my_error(ER_CANNOT_LOAD_SLAVE_GTID_STATE, MYF(0), "mysql", + rpl_gtid_slave_state_table_name.str); + return NULL; + } str.length(0); if ((opt_bin_log && mysql_bin_log.append_state_pos(&str)) || !(p= thd->strmake(str.ptr(), str.length()))) @@ -1308,6 +1314,14 @@ Sys_var_gtid_slave_pos::do_check(THD *thd, set_var *var) bool running; DBUG_ASSERT(var->type == OPT_GLOBAL); + + if (!rpl_global_gtid_slave_state.loaded) + { + my_error(ER_CANNOT_LOAD_SLAVE_GTID_STATE, MYF(0), "mysql", + rpl_gtid_slave_state_table_name.str); + return true; + } + mysql_mutex_lock(&LOCK_active_mi); running= master_info_index->give_error_if_slave_running(); mysql_mutex_unlock(&LOCK_active_mi); @@ -1366,6 +1380,13 @@ Sys_var_gtid_slave_pos::global_value_ptr(THD *thd, LEX_STRING *base) String str; char *p; + if (!rpl_global_gtid_slave_state.loaded) + { + my_error(ER_CANNOT_LOAD_SLAVE_GTID_STATE, MYF(0), "mysql", + rpl_gtid_slave_state_table_name.str); + return NULL; + } + str.length(0); if (rpl_append_gtid_state(&str, false) || !(p= thd->strmake(str.ptr(), str.length()))) |