Commit 8ef20518 authored by Alexey Kopytov's avatar Alexey Kopytov

Automerge

parents 19c0d4a0 7ae9387c
......@@ -212,3 +212,31 @@ start slave sql_thread;
start slave until master_log_file='master-bin.000001', master_log_pos=776;
Warnings:
Note 1254 Slave is already running
include/stop_slave.inc
drop table if exists t1;
reset slave;
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
drop table if exists t1;
reset master;
create table t1 (a int primary key auto_increment);
start slave;
include/stop_slave.inc
master and slave are in sync now
select 0 as zero;
zero
0
insert into t1 set a=null;
insert into t1 set a=null;
select count(*) as two from t1;
two
2
start slave until master_log_file='master-bin.000001', master_log_pos= UNTIL_POS;;
slave stopped at the prescribed position
select 0 as zero;
zero
0
select count(*) as one from t1;
one
1
drop table t1;
start slave;
......@@ -98,3 +98,67 @@ start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
start slave sql_thread;
start slave until master_log_file='master-bin.000001', master_log_pos=776;
#
# bug#47210 first execution of "start slave until" stops too early
#
# testing that a slave rotate event that is caused by stopping the slave
# does not intervene anymore in UNTIL condition.
#
connection slave;
source include/stop_slave.inc;
--disable_warnings
drop table if exists t1;
--enable_warnings
reset slave;
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
connection master;
--disable_warnings
drop table if exists t1;
--enable_warnings
reset master;
create table t1 (a int primary key auto_increment);
save_master_pos;
let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
connection slave;
start slave;
sync_with_master;
# at this point slave will close the relay log stamping it with its own
# Rotate log event. This event won't be examined on matter of the master
# UNTIL pos anymore.
source include/stop_slave.inc;
let $slave_exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
--echo master and slave are in sync now
let $diff_pos= `select $master_pos - $slave_exec_pos`;
eval select $diff_pos as zero;
connection master;
insert into t1 set a=null;
let $until_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
insert into t1 set a=null;
select count(*) as two from t1;
connection slave;
--replace_result $until_pos UNTIL_POS;
eval start slave until master_log_file='master-bin.000001', master_log_pos= $until_pos;
source include/wait_for_slave_sql_to_stop.inc;
let $slave_exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
--echo slave stopped at the prescribed position
let $diff_pos= `select $until_pos - $slave_exec_pos`;
eval select $diff_pos as zero;
select count(*) as one from t1;
connection master;
drop table t1;
connection slave;
start slave;
sync_with_master;
# End of tests
......@@ -1022,7 +1022,7 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
false - condition not met
*/
bool Relay_log_info::is_until_satisfied(my_off_t master_beg_pos)
bool Relay_log_info::is_until_satisfied(THD *thd, Log_event *ev)
{
const char *log_name;
ulonglong log_pos;
......@@ -1032,8 +1032,12 @@ bool 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)
DBUG_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 */
......
......@@ -303,7 +303,7 @@ class Relay_log_info : public Slave_reporting_capability
void close_temporary_tables();
/* Check if UNTIL condition is satisfied. See slave.cc for more. */
bool is_until_satisfied(my_off_t master_beg_pos);
bool is_until_satisfied(THD *thd, Log_event *ev);
inline ulonglong until_pos()
{
return ((until_condition == UNTIL_MASTER_POS) ? group_master_log_pos :
......
......@@ -2258,9 +2258,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((rli->is_in_group() || !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"
......@@ -3003,7 +3001,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
*/
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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment