mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 03:21:53 +01:00
07ffa9c767
=== 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. mysql-test/suite/engines/funcs/r/rpl_row_until.result: modified to accomodate the changes in corresponding test file. mysql-test/suite/engines/funcs/t/disabled.def: removed from the list of disabled tests. mysql-test/suite/engines/funcs/t/rpl_row_until.test: fixed rpl.rpl_row_until and copied its content to engines/funcs.rpl_row_until. The reason being both are same tests but rpl.rpl_row_until is an updated version. mysql-test/suite/rpl/t/disabled.def: removed from the list of disabled tests. sql/sql_repl.cc: Added a check to catch an improper combination of arguements passed to 'START SLAVE UNTIL'. Earlier, START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=561, RELAY_LOG_POS=12; passed. It is now detected and an error is reported.
127 lines
4.6 KiB
Text
127 lines
4.6 KiB
Text
-- source include/not_ndb_default.inc
|
|
-- source include/have_binlog_format_row.inc
|
|
-- source include/master-slave.inc
|
|
|
|
# Note: The test is dependent on binlog positions
|
|
|
|
# Create some events on master
|
|
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);
|
|
|
|
CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
|
|
# Save master log position for query CREATE TABLE t2
|
|
save_master_pos;
|
|
let $master_pos_create_t2= query_get_value(SHOW BINLOG EVENTS, Pos, 8);
|
|
|
|
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;
|
|
INSERT INTO t2 VALUES (3),(4);
|
|
DROP TABLE t2;
|
|
# Save master log position for query INSERT INTO t2 VALUES (1),(2);
|
|
let $master_pos_drop_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 17);
|
|
sync_slave_with_master;
|
|
|
|
--source include/stop_slave.inc
|
|
# Reset slave.
|
|
RESET SLAVE;
|
|
--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;
|
|
echo START SLAVE UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=master_pos_drop_t1;
|
|
--disable_query_log
|
|
eval START SLAVE UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=$master_pos_drop_t1;
|
|
--enable_query_log
|
|
--source include/wait_for_slave_sql_to_stop.inc
|
|
|
|
# Here table should be still not deleted
|
|
SELECT * FROM t1;
|
|
--let $slave_param= Exec_Master_Log_Pos
|
|
--let $slave_param_value= $master_pos_drop_t1
|
|
--source include/check_slave_param.inc
|
|
|
|
# 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
|
|
SELECT * FROM t1;
|
|
|
|
--let $slave_param= Exec_Master_Log_Pos
|
|
--let $slave_param_value= $master_pos_drop_t1
|
|
--source include/check_slave_param.inc
|
|
|
|
# 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;
|
|
--disable_query_log
|
|
eval START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=$relay_pos_insert1_t2;
|
|
--enable_query_log
|
|
--source include/wait_for_slave_sql_to_stop.inc
|
|
SELECT * FROM t2;
|
|
|
|
--let $slave_param= Exec_Master_Log_Pos
|
|
--let $slave_param_value= $master_pos_insert1_t2
|
|
--source include/check_slave_param.inc
|
|
|
|
# clean up
|
|
START SLAVE;
|
|
--source include/wait_for_slave_to_start.inc
|
|
connection master;
|
|
sync_slave_with_master;
|
|
--source include/stop_slave.inc
|
|
|
|
# This should stop immediately as we are already there
|
|
echo START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=master_pos_create_t2;
|
|
--disable_query_log
|
|
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
|
|
--let $slave_param= Exec_Master_Log_Pos
|
|
--let $slave_param_value= $master_pos_drop_t2
|
|
--source include/check_slave_param.inc
|
|
|
|
#testing various error conditions
|
|
--replace_result 561 MASTER_LOG_POS
|
|
--error 1277
|
|
START SLAVE UNTIL MASTER_LOG_FILE='master-bin', MASTER_LOG_POS=561;
|
|
--replace_result 561 MASTER_LOG_POS 12 RELAY_LOG_POS
|
|
--error 1277
|
|
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=561, RELAY_LOG_POS=12;
|
|
--error 1277
|
|
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001';
|
|
--error 1277
|
|
START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000009';
|
|
--replace_result 561 MASTER_LOG_POS
|
|
--error 1277
|
|
START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=561;
|
|
# Warning should be given for second command
|
|
START SLAVE;
|
|
--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
|