Commit daeda052 authored by Shivji Kumar Jha's avatar Shivji Kumar Jha

BUG#12359942 - REPLICATION TEST FROM ENGINE SUITE RPL_ROW_UNTIL TIMES OUT

=== Problem ===

The test is dependent on binlog positions and checks
to see if the command 'START SLAVE' functions correctly
with the 'UNTIL' clause added to it. The 'UNTIL' clause
is added to specify that the slave should start and run
until the SQL thread reaches a given point in the master
binary log or in the slave relay log.

The test uses hard coded values for MASTER_LOG_POS and
RELAY_LOG_POS, instead of extracting it using
query_get_value() function. There is a test
'rpl.rpl_row_until' which does the similar thing but uses 
query_get_value() function to set the values of
MASTER_LOG_POS/ RELAY_LOG_POS. To be precise,
rpl.rpl_row_until is a modified version of
engines/func.rpl_row_until.test.

The use of hard coded values may lead the slave to stop at a position
which may differ from the expected position in the binlog file,
an example being the failure of engines/funcs.rpl_row_until in 
mysql-5.1 given as: 
"query 'select * from t2' failed. Table 'test.t2' doesn't exist".
In this case, the slave actually ran a couple of extra commands
as a result of which the slave first deleted the table and then
ran a select query on table, leading to the above mentioned failure.

=== Fix ===

1) Fixed the code for failure seen in rpl.rpl_row_until.
   This test was also failing although the symptoms of
   failure were different.
2) Copied the contents from rpl.rpl_row_until into
   into engines/funcs.rpl.rpl_row_until.
3) Updated engines/funcs.rpl_row_until.result accordingly.
parent bc6287a3
stop slave; include/master-slave.inc
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; [connection master]
reset master; CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
reset slave; INSERT INTO t1 VALUES (1),(2),(3),(4);
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; DROP TABLE t1;
start slave; CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
stop slave; INSERT INTO t2 VALUES (1),(2);
create table t1(n int not null auto_increment primary key); INSERT INTO t2 VALUES (3),(4);
insert into t1 values (1),(2),(3),(4); DROP TABLE t2;
drop table t1; include/stop_slave.inc
create table t2(n int not null auto_increment primary key); RESET SLAVE;
insert into t2 values (1),(2); START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_drop_t1
insert into t2 values (3),(4); include/wait_for_slave_sql_to_stop.inc
drop table t2; SELECT * FROM t1;
start slave until master_log_file='master-bin.000001', master_log_pos=311;
select * from t1;
n n
1 1
2 2
3 3
4 4
show slave status; include/check_slave_param.inc [Exec_Master_Log_Pos]
Slave_IO_State # START SLAVE UNTIL MASTER_LOG_FILE='master-no-such-bin.000001', MASTER_LOG_POS=MASTER_LOG_POS;
Master_Host 127.0.0.1 include/wait_for_slave_sql_to_stop.inc
Master_User root SELECT * FROM t1;
Master_Port MASTER_MYPORT n
Connect_Retry 1 1
Master_Log_File master-bin.000001 2
Read_Master_Log_Pos # 3
Relay_Log_File slave-relay-bin.000004 4
Relay_Log_Pos # include/check_slave_param.inc [Exec_Master_Log_Pos]
Relay_Master_Log_File master-bin.000001 START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=relay_pos_insert1_t2
Slave_IO_Running # include/wait_for_slave_sql_to_stop.inc
Slave_SQL_Running No SELECT * FROM t2;
Replicate_Do_DB n
Replicate_Ignore_DB 1
Replicate_Do_Table 2
Replicate_Ignore_Table include/check_slave_param.inc [Exec_Master_Log_Pos]
Replicate_Wild_Do_Table START SLAVE;
Replicate_Wild_Ignore_Table include/wait_for_slave_to_start.inc
Last_Errno 0 include/stop_slave.inc
Last_Error START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_create_t2
Skip_Counter 0 include/wait_for_slave_param.inc [Until_Log_Pos]
Exec_Master_Log_Pos # include/wait_for_slave_sql_to_stop.inc
Relay_Log_Space # include/check_slave_param.inc [Exec_Master_Log_Pos]
Until_Condition Master START SLAVE UNTIL MASTER_LOG_FILE='master-bin', MASTER_LOG_POS=MASTER_LOG_POS;
Until_Log_File master-bin.000001
Until_Log_Pos 311
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
select * from t1;
n 1
n 2
n 3
n 4
show slave status;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_MYPORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File slave-relay-bin.000004
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running #
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos #
Relay_Log_Space #
Until_Condition Master
Until_Log_File master-no-such-bin.000001
Until_Log_Pos 291
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=728;
select * from t2;
show slave status;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_MYPORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File slave-relay-bin.000004
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running #
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos #
Relay_Log_Space #
Until_Condition Relay
Until_Log_File slave-relay-bin.000004
Until_Log_Pos 728
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
start slave;
stop slave;
start slave until master_log_file='master-bin.000001', master_log_pos=740;
show slave status;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
Master_Port MASTER_MYPORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File slave-relay-bin.000004
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos #
Relay_Log_Space #
Until_Condition Master
Until_Log_File master-bin.000001
Until_Log_Pos 740
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
start slave until master_log_file='master-bin', master_log_pos=561;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=MASTER_LOG_POS, RELAY_LOG_POS=RELAY_LOG_POS;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
start slave until master_log_file='master-bin.000001'; START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001';
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
start slave until relay_log_file='slave-relay-bin.000002'; START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000009';
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561; START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=MASTER_LOG_POS;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
start slave sql_thread; START SLAVE;
start slave until master_log_file='master-bin.000001', master_log_pos=740; START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=MASTER_LOG_POS;
Warnings: Warnings:
Level Note Note 1254 Slave is already running
Code 1254 include/stop_slave.inc
Message Slave is already running RESET SLAVE;
include/rpl_end.inc
...@@ -72,7 +72,6 @@ rpl000017 : Result Difference Due to Change in .inc file ...@@ -72,7 +72,6 @@ rpl000017 : Result Difference Due to Change in .inc file
rpl_skip_error : Result Difference Due to Change in .inc file rpl_skip_error : Result Difference Due to Change in .inc file
rpl_sp : Result Difference Due to Change in .inc file rpl_sp : Result Difference Due to Change in .inc file
rpl_row_until : Test Present in rpl suite as well . Test Fails with table t2 not found.
rpl_loaddata_s : Test Present in rpl suite as well . Test Fails due to bin log truncation. rpl_loaddata_s : Test Present in rpl suite as well . Test Fails due to bin log truncation.
rpl_log_pos : Test Present in rpl suite as well . Test Fails due to bin log truncation. rpl_log_pos : Test Present in rpl suite as well . Test Fails due to bin log truncation.
rpl_row_NOW : Result Difference Due to Change in .inc file rpl_row_NOW : Result Difference Due to Change in .inc file
......
...@@ -2,90 +2,126 @@ ...@@ -2,90 +2,126 @@
-- source include/have_binlog_format_row.inc -- source include/have_binlog_format_row.inc
-- source include/master-slave.inc -- source include/master-slave.inc
# Test is dependent on binlog positions # Note: The test is dependent on binlog positions
# prepare version for substitutions # Create some events on master
let $VERSION=`select version()`; connection master;
CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2),(3),(4);
DROP TABLE t1;
# Save master log position for query DROP TABLE t1
save_master_pos;
let $master_pos_drop_t1= query_get_value(SHOW BINLOG EVENTS, Pos, 7);
let $master_log_file= query_get_value(SHOW BINLOG EVENTS, Log_name, 7);
# stop slave before he will start replication also sync with master CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
# for avoiding undetermenistic behaviour # Save master log position for query CREATE TABLE t2
save_master_pos; save_master_pos;
connection slave; let $master_pos_create_t2= query_get_value(SHOW BINLOG EVENTS, Pos, 8);
sync_with_master;
stop slave; INSERT INTO t2 VALUES (1),(2);
save_master_pos;
# Save master log position for query INSERT INTO t2 VALUES (1),(2);
let $master_pos_insert1_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 12);
sync_slave_with_master;
# Save relay log position for query INSERT INTO t2 VALUES (1),(2);
let $relay_pos_insert1_t2= query_get_value(show slave status, Relay_Log_Pos, 1);
connection master; connection master;
# create some events on master INSERT INTO t2 VALUES (3),(4);
create table t1(n int not null auto_increment primary key); DROP TABLE t2;
insert into t1 values (1),(2),(3),(4); # Save master log position for query INSERT INTO t2 VALUES (1),(2);
drop table t1; let $master_pos_drop_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 17);
create table t2(n int not null auto_increment primary key); sync_slave_with_master;
insert into t2 values (1),(2);
insert into t2 values (3),(4); --source include/stop_slave.inc
drop table t2; # Reset slave.
RESET SLAVE;
# try to replicate all queries until drop of t1 --disable_query_log
eval CHANGE MASTER TO MASTER_USER='root', MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT;
--enable_query_log
# Try to replicate all queries until drop of t1
connection slave; connection slave;
start slave until master_log_file='master-bin.000001', master_log_pos=311; echo START SLAVE UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=master_pos_drop_t1;
sleep 2; --disable_query_log
wait_for_slave_to_stop; eval START SLAVE UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=$master_pos_drop_t1;
# here table should be still not deleted --enable_query_log
select * from t1; --source include/wait_for_slave_sql_to_stop.inc
--vertical_results
--replace_result $MASTER_MYPORT MASTER_MYPORT # Here table should be still not deleted
--replace_column 1 # 7 # 9 # 11 # 22 # 23 # 33 # SELECT * FROM t1;
show slave status; --let $slave_param= Exec_Master_Log_Pos
--let $slave_param_value= $master_pos_drop_t1
# this should fail right after start --source include/check_slave_param.inc
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
# This should fail right after start
--replace_result 291 MASTER_LOG_POS
START SLAVE UNTIL MASTER_LOG_FILE='master-no-such-bin.000001', MASTER_LOG_POS=291;
--source include/wait_for_slave_sql_to_stop.inc
# again this table should be still not deleted # again this table should be still not deleted
select * from t1; SELECT * FROM t1;
sleep 2;
wait_for_slave_to_stop; --let $slave_param= Exec_Master_Log_Pos
--vertical_results --let $slave_param_value= $master_pos_drop_t1
--replace_result $MASTER_MYPORT MASTER_MYPORT --source include/check_slave_param.inc
--replace_column 1 # 7 # 9 # 11 # 22 # 23 # 33 #
show slave status; # Try replicate all up to and not including the second insert to t2;
echo START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=relay_pos_insert1_t2;
# try replicate all up to and not including the second insert to t2; --disable_query_log
start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=728; eval START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=$relay_pos_insert1_t2;
sleep 2; --enable_query_log
wait_for_slave_to_stop; --source include/wait_for_slave_sql_to_stop.inc
select * from t2; SELECT * FROM t2;
--vertical_results
--replace_result $MASTER_MYPORT MASTER_MYPORT --let $slave_param= Exec_Master_Log_Pos
--replace_column 1 # 7 # 9 # 11 # 22 # 23 # 33 # --let $slave_param_value= $master_pos_insert1_t2
show slave status; --source include/check_slave_param.inc
# clean up # clean up
start slave; START SLAVE;
--source include/wait_for_slave_to_start.inc
connection master; connection master;
save_master_pos; sync_slave_with_master;
connection slave; --source include/stop_slave.inc
sync_with_master;
stop slave;
# this should stop immediately as we are already there # This should stop immediately as we are already there
start slave until master_log_file='master-bin.000001', master_log_pos=740; echo START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=master_pos_create_t2;
sleep 2; --disable_query_log
wait_for_slave_to_stop; eval START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=$master_pos_create_t2;
--enable_query_log
let $slave_param= Until_Log_Pos;
let $slave_param_value= $master_pos_create_t2;
--source include/wait_for_slave_param.inc
--source include/wait_for_slave_sql_to_stop.inc
# here the sql slave thread should be stopped # here the sql slave thread should be stopped
--vertical_results --let $slave_param= Exec_Master_Log_Pos
--replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004 --let $slave_param_value= $master_pos_drop_t2
--replace_column 1 # 7 # 9 # 22 # 23 # 33 # --source include/check_slave_param.inc
show slave status;
#testing various error conditions #testing various error conditions
--replace_result 561 MASTER_LOG_POS
--error 1277 --error 1277
start slave until master_log_file='master-bin', master_log_pos=561; START SLAVE UNTIL MASTER_LOG_FILE='master-bin', MASTER_LOG_POS=561;
--replace_result 561 MASTER_LOG_POS 12 RELAY_LOG_POS
--error 1277 --error 1277
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=561, RELAY_LOG_POS=12;
--error 1277 --error 1277
start slave until master_log_file='master-bin.000001'; START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001';
--error 1277 --error 1277
start slave until relay_log_file='slave-relay-bin.000002'; START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000009';
--replace_result 561 MASTER_LOG_POS
--error 1277 --error 1277
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561; START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=561;
# Warning should be given for second command # Warning should be given for second command
start slave sql_thread; START SLAVE;
start slave until master_log_file='master-bin.000001', master_log_pos=740; --replace_result 740 MASTER_LOG_POS
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=740;
--source include/stop_slave.inc
# Clear slave IO error.
RESET SLAVE;
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc
...@@ -12,5 +12,4 @@ ...@@ -12,5 +12,4 @@
rpl_row_create_table : Bug#11759274 Feb 27 2010 andrei failed different way than earlier with bug#45576 rpl_row_create_table : Bug#11759274 Feb 27 2010 andrei failed different way than earlier with bug#45576
rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock
rpl_row_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out rpl_stm_until : BUG#59543 Jan 26 2011 alfranio Replication test from eits suite rpl_row_until times out
...@@ -869,6 +869,8 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) ...@@ -869,6 +869,8 @@ int start_slave(THD* thd , Master_info* mi, bool net_report)
if (thd->lex->mi.pos) if (thd->lex->mi.pos)
{ {
if (thd->lex->mi.relay_log_pos)
slave_errno=ER_BAD_SLAVE_UNTIL_COND;
mi->rli.until_condition= Relay_log_info::UNTIL_MASTER_POS; mi->rli.until_condition= Relay_log_info::UNTIL_MASTER_POS;
mi->rli.until_log_pos= thd->lex->mi.pos; mi->rli.until_log_pos= thd->lex->mi.pos;
/* /*
...@@ -880,6 +882,8 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) ...@@ -880,6 +882,8 @@ int start_slave(THD* thd , Master_info* mi, bool net_report)
} }
else if (thd->lex->mi.relay_log_pos) else if (thd->lex->mi.relay_log_pos)
{ {
if (thd->lex->mi.pos)
slave_errno=ER_BAD_SLAVE_UNTIL_COND;
mi->rli.until_condition= Relay_log_info::UNTIL_RELAY_POS; mi->rli.until_condition= Relay_log_info::UNTIL_RELAY_POS;
mi->rli.until_log_pos= thd->lex->mi.relay_log_pos; mi->rli.until_log_pos= thd->lex->mi.relay_log_pos;
strmake(mi->rli.until_log_name, thd->lex->mi.relay_log_name, strmake(mi->rli.until_log_name, thd->lex->mi.relay_log_name,
......
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