summaryrefslogtreecommitdiff
path: root/sql/rpl_rli.cc
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2013-06-03 07:41:38 +0200
committerunknown <knielsen@knielsen-hq.org>2013-06-03 07:41:38 +0200
commit7ad47ab0e080ca66f8a41de461b036d3bdff25fb (patch)
tree2f66464864677488b7b882522e50cb2aea58a4f4 /sql/rpl_rli.cc
parent6feadb10823c352b1eb9b24682c7d24d32175b0f (diff)
downloadmariadb-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/rpl_rli.cc')
-rw-r--r--sql/rpl_rli.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 03ec77e1433..9cb210f398f 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1425,7 +1425,10 @@ rpl_load_gtid_slave_state(THD *thd)
bitmap_set_all(table->read_set);
if ((err= table->file->ha_rnd_init_with_error(1)))
+ {
+ table->file->print_error(err, MYF(0));
goto end;
+ }
table_scanned= true;
for (;;)
{
@@ -1440,7 +1443,10 @@ rpl_load_gtid_slave_state(THD *thd)
else if (err == HA_ERR_END_OF_FILE)
break;
else
+ {
+ table->file->print_error(err, MYF(0));
goto end;
+ }
}
domain_id= (ulonglong)table->field[0]->val_int();
sub_id= (ulonglong)table->field[1]->val_int();
@@ -1465,6 +1471,7 @@ rpl_load_gtid_slave_state(THD *thd)
if (!(entry= (struct local_element *)my_malloc(sizeof(*entry),
MYF(MY_WME))))
{
+ my_error(ER_OUTOFMEMORY, MYF(0), (int)sizeof(*entry));
err= 1;
goto end;
}
@@ -1475,12 +1482,18 @@ rpl_load_gtid_slave_state(THD *thd)
if ((err= my_hash_insert(&hash, (uchar *)entry)))
{
my_free(entry);
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto end;
}
}
}
rpl_global_gtid_slave_state.lock();
+ if (rpl_global_gtid_slave_state.loaded)
+ {
+ rpl_global_gtid_slave_state.unlock();
+ goto end;
+ }
for (i= 0; i < hash.records; ++i)
{
entry= (struct local_element *)my_hash_element(&hash, i);
@@ -1490,14 +1503,15 @@ rpl_load_gtid_slave_state(THD *thd)
entry->gtid.seq_no)))
{
rpl_global_gtid_slave_state.unlock();
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto end;
}
if (opt_bin_log &&
mysql_bin_log.bump_seq_no_counter_if_needed(entry->gtid.domain_id,
entry->gtid.seq_no))
{
- my_error(ER_OUT_OF_RESOURCES, MYF(0));
rpl_global_gtid_slave_state.unlock();
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto end;
}
}