Commit 6c6afd71 authored by svoj@june.mysql.com's avatar svoj@june.mysql.com

Merge mysql.com:/home/svoj/devel/mysql/BUG13861/mysql-5.0-engines

into  mysql.com:/home/svoj/devel/mysql/BUG13861/mysql-5.1-engines
parents ef957961 44340d93
......@@ -8,15 +8,56 @@ reset master;
change master to master_host="127.0.0.1",master_port=SLAVE_PORT,master_user="root";
start slave;
create table t1 (n int);
stop slave;
create table t2 (n int);
show tables;
Tables_in_test
t1
t2
create table t3 (n int) engine=innodb;
set @a=1;
insert into t3 values(@a);
begin;
insert into t3 values(2);
insert into t3 values(3);
commit;
insert into t3 values(4);
start slave until master_log_file="slave-bin.000001",master_log_pos=195;
Warnings:
Note 1278 It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mysqld restart
select master_pos_wait("slave-bin.000001",137);
master_pos_wait("slave-bin.000001",137)
0
show tables;
Tables_in_test
t1
t2
start slave until master_log_file="slave-bin.000001",master_log_pos=438;
Warnings:
Note 1278 It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mysqld restart
select * from t3;
n
1
start slave until master_log_file="slave-bin.000001",master_log_pos=663;
Warnings:
Note 1278 It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mysqld restart
select * from t3;
n
1
2
3
start slave;
create table t4 (n int);
create table t5 (n int);
create table t6 (n int);
show tables;
Tables_in_test
t1
t2
t3
t4
t5
t6
stop slave;
reset slave;
drop table t1,t4,t5,t6;
drop table t1,t2,t3,t4,t5,t6;
......@@ -7,6 +7,7 @@
# It also will test BUG#13861.
source include/master-slave.inc;
source include/have_innodb.inc;
# set up "dual head"
......@@ -30,45 +31,64 @@ save_master_pos;
connection master;
sync_with_master;
# Now test BUG#13861. This will be enabled when Guilhem fixes this
# bug.
#
# BUG#13861 - START SLAVE UNTIL may stop 1 evnt too late if
# log-slave-updates and circul repl
#
stop slave;
# stop slave
create table t2 (n int); # create one ignored event
# create table t2 (n int); # create one ignored event
save_master_pos;
connection slave;
sync_with_master;
# save_master_pos;
# connection slave;
# sync_with_master;
connection slave;
# connection slave;
show tables;
# show tables;
save_master_pos;
# save_master_pos;
create table t3 (n int) engine=innodb;
set @a=1;
insert into t3 values(@a);
begin;
insert into t3 values(2);
insert into t3 values(3);
commit;
insert into t3 values(4);
# create table t3 (n int);
# connection master;
connection master;
# bug is that START SLAVE UNTIL may stop too late, we test that by
# asking it to stop before creation of t3.
# start slave until master_log_file="slave-bin.000001",master_log_pos=195;
start slave until master_log_file="slave-bin.000001",master_log_pos=195;
# wait until it's started (the position below is the start of "CREATE
# TABLE t2") (otherwise wait_for_slave_to_stop may return at once)
# select master_pos_wait("slave-bin.000001",137);
select master_pos_wait("slave-bin.000001",137);
# --source include/wait_for_slave_to_stop.inc
--source include/wait_for_slave_to_stop.inc
# then BUG#13861 causes t3 to show up below (because stopped too
# late).
# show tables;
show tables;
# ensure that we do not break set @a=1; insert into t3 values(@a);
start slave until master_log_file="slave-bin.000001",master_log_pos=438;
--source include/wait_for_slave_to_stop.inc
select * from t3;
# ensure that we do not break transaction
start slave until master_log_file="slave-bin.000001",master_log_pos=663;
--source include/wait_for_slave_to_stop.inc
select * from t3;
# start slave;
start slave;
# BUG#13023 is that Exec_master_log_pos may stay too low "forever":
......@@ -99,7 +119,7 @@ show tables;
stop slave;
reset slave;
drop table t1,t4,t5,t6; # add t2 and t3 later
drop table t1,t2,t3,t4,t5,t6;
save_master_pos;
connection slave;
......
......@@ -603,6 +603,7 @@ Log_event::Log_event(const char* buf,
#endif
when = uint4korr(buf);
server_id = uint4korr(buf + SERVER_ID_OFFSET);
data_written= uint4korr(buf + EVENT_LEN_OFFSET);
if (description_event->binlog_version==1)
{
log_pos= 0;
......@@ -635,7 +636,7 @@ Log_event::Log_event(const char* buf,
binlog, so which will cause problems if the user uses this value
in CHANGE MASTER).
*/
log_pos+= uint4korr(buf + EVENT_LEN_OFFSET);
log_pos+= data_written;
}
DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos));
......
......@@ -1971,16 +1971,29 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
wait for something for example inside of next_event().
*/
pthread_mutex_lock(&rli->data_lock);
Log_event * ev = next_event(rli);
DBUG_ASSERT(rli->sql_thd==thd);
if (sql_slave_killed(thd,rli))
{
pthread_mutex_unlock(&rli->data_lock);
delete ev;
DBUG_RETURN(1);
}
if (ev)
{
int exec_res;
/*
This tests if the position of the end of the last previous executed event
This tests if the position of the beginning of the current event
hits the UNTIL barrier.
We would prefer to test if the position of the start (or possibly) end of
the to-be-read event hits the UNTIL barrier, this is different if there
was an event ignored by the I/O thread just before (BUG#13861 to be
fixed).
*/
if (rli->until_condition!=Relay_log_info::UNTIL_NONE &&
rli->is_until_satisfied())
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))
{
char buf[22];
sql_print_information("Slave SQL thread stopped because it reached its"
......@@ -1990,23 +2003,11 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli)
error in query execution to be printed.
*/
rli->abort_slave= 1;
pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1);
}
Log_event * ev = next_event(rli);
DBUG_ASSERT(rli->sql_thd==thd);
if (sql_slave_killed(thd,rli))
{
pthread_mutex_unlock(&rli->data_lock);
delete ev;
DBUG_RETURN(1);
}
if (ev)
{
int exec_res= apply_event_and_update_pos(ev, thd, rli, TRUE);
exec_res= apply_event_and_update_pos(ev, thd, rli, TRUE);
/*
Format_description_log_event should not be deleted because it will be
......@@ -2642,6 +2643,22 @@ Slave SQL thread aborted. Can't execute init_slave query");
}
}
/*
First check until condition - probably there is nothing to execute. We
do not want to wait for next event in this case.
*/
pthread_mutex_lock(&rli->data_lock);
if (rli->until_condition != RELAY_LOG_INFO::UNTIL_NONE &&
rli->is_until_satisfied(rli->group_master_log_pos))
{
char buf[22];
sql_print_information("Slave SQL thread stopped because it reached its"
" UNTIL position %s", llstr(rli->until_pos(), buf));
pthread_mutex_unlock(&rli->data_lock);
goto err;
}
pthread_mutex_unlock(&rli->data_lock);
/* Read queries from the IO/THREAD until this thread is killed */
while (!sql_slave_killed(thd,rli))
......
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