summaryrefslogtreecommitdiff
path: root/sql/slave.cc
diff options
context:
space:
mode:
authorAndrei Elkin <aelkin@mysql.com>2009-11-12 17:10:19 +0200
committerAndrei Elkin <aelkin@mysql.com>2009-11-12 17:10:19 +0200
commitf1abd015dcec3c1347e96e6197db8fd05c021537 (patch)
treeab45a9bfc2849e5605f4856f8059a8f829ff15a9 /sql/slave.cc
parent903d21287c835fa76cd3eac7b00276b5195eda3a (diff)
downloadmariadb-git-f1abd015dcec3c1347e96e6197db8fd05c021537.tar.gz
Bug #47210 first execution of "start slave until" stops too early
Until-pos guarding did not distiguish the master originated events from ones that the slave can introduce to the relay log e.g Rotate to the next relay log at slave restarting. The local Rotate's coordinate are incomparable with the Until-master-pos. That led to the unexpectable stop this bug describes. Fixed with to avoid Until-master-pos comparison for a local slave's event. Notice that if --replicate-same-server is true such event is treated as coming from the master side. mysql-test/r/rpl_until.result: results changed. mysql-test/t/rpl_until.test: regression test for bug#47210 is added. sql/slave.cc: st_relay_log_info::is_until_satisfied() is augmented with avoidance of Until-master-pos comparison for a local slave's event. if --replicate-same-server is true such event is treated as coming from the master side. sql/slave.h: signature of is_until_satisfied() changed to supply THD and Event to the routine.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r--sql/slave.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index dd29a3f45c9..87bd7e2be8c 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3223,7 +3223,7 @@ int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error)
false - condition not met
*/
-bool st_relay_log_info::is_until_satisfied(my_off_t master_beg_pos)
+bool st_relay_log_info::is_until_satisfied(THD *thd, Log_event *ev)
{
const char *log_name;
ulonglong log_pos;
@@ -3232,8 +3232,12 @@ bool st_relay_log_info::is_until_satisfied(my_off_t master_beg_pos)
if (until_condition == UNTIL_MASTER_POS)
{
+ if (ev && ev->server_id == (uint32) ::server_id && !replicate_same_server_id)
+ return FALSE;
log_name= group_master_log_name;
- log_pos= master_beg_pos;
+ log_pos= (!ev)? group_master_log_pos :
+ ((thd->options & OPTION_BEGIN || !ev->log_pos) ?
+ group_master_log_pos : ev->log_pos - ev->data_written);
}
else
{ /* until_condition == UNTIL_RELAY_POS */
@@ -3333,9 +3337,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
hits the UNTIL barrier.
*/
if (rli->until_condition != RELAY_LOG_INFO::UNTIL_NONE &&
- rli->is_until_satisfied((thd->options & OPTION_BEGIN || !ev->log_pos) ?
- rli->group_master_log_pos :
- ev->log_pos - ev->data_written))
+ rli->is_until_satisfied(thd, ev))
{
char buf[22];
sql_print_information("Slave SQL thread stopped because it reached its"
@@ -4065,7 +4067,7 @@ Slave SQL thread aborted. Can't execute init_slave query");
*/
pthread_mutex_lock(&rli->data_lock);
if (rli->until_condition != RELAY_LOG_INFO::UNTIL_NONE &&
- rli->is_until_satisfied(rli->group_master_log_pos))
+ rli->is_until_satisfied(thd, NULL))
{
char buf[22];
sql_print_information("Slave SQL thread stopped because it reached its"