mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 06:44:16 +01:00
6e69536956
Problem 1: tests often fail in pushbuild with a timeout when waiting for the slave to start/stop/receive error. Fix 1: Updated the wait_for_slave_* macros in the following way: - The timeout is increased by a factor ten - Refactored the macros so that wait_for_slave_param does the work for the other macros. Problem 2: Tests are often incorrectly written, lacking a source include/wait_for_slave_to_[start|stop].inc. Fix 2: Improved the chance to get it right by adding include/start_slave.inc and include/stop_slave.inc, and updated tests to use these. Problem 3: The the built-in test language command wait_for_slave_to_stop is a misnomer (does not wait for the slave io thread) and does not give as much debug info in case of failure as the otherwise equivalent macro source include/wait_for_slave_sql_to_stop.inc Fix 3: Replaced all calls to the built-in command by a call to the macro. Problem 4: Some, but not all, of the wait_for_slave_* macros had an implicit connection slave. This made some tests confusing to read, and made it more difficult to use the macro in circular replication scenarios, where the connection named master needs to wait. Fix 4: Removed the implicit connection slave from all wait_for_slave_* macros, and updated tests to use an explicit connection slave where necessary. Problem 5: The macros wait_slave_status.inc and wait_show_pattern.inc were unused. Moreover, using them is difficult and error-prone. Fix 5: remove these macros. Problem 6: log_bin_trust_function_creators_basic failed when running tests because it assumed @@global.log_bin_trust_function_creators=1, and some tests modified this variable without resetting it to its original value. Fix 6: All tests that use this variable have been updated so that they reset the value at end of test. mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test: Replaced wait_for_slave_to_stop by include/wait_for_slave_sql_to_stop.inc mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test: Replaced wait_for_slave_to_stop by include/wait_for_slave_sql_to_stop.inc Added connection slave since includ/wait_for_slave_sql_to_stop.inc does not do that anymore. mysql-test/extra/rpl_tests/rpl_log.test: Replaced start slave+wait_slave_status by start_slave.inc mysql-test/include/reset_master_and_slave.inc: replaced start/stop slave by start_slave.inc/stop_slave.inc mysql-test/include/sync_slave_io_with_master.inc: Improved comments and error message. mysql-test/include/wait_for_slave_io_to_stop.inc: Refactored to use wait_for_slave_param.inc. Removed connection slave. mysql-test/include/wait_for_slave_param.inc: - Improved usage instructions - Added more debug info in case of timeout - Added parameters $slave_param_comparison, $slave_timeout, $slave_keep_connection, $slave_error_message mysql-test/include/wait_for_slave_sql_error.inc: Refactored to use wait_for_slave_param.inc. Removed connection slave. mysql-test/include/wait_for_slave_sql_to_start.inc: Refactored to use wait_for_slave_param.inc. Removed connection slave. mysql-test/include/wait_for_slave_sql_to_stop.inc: Refactored to use wait_for_slave_param.inc. Removed connection slave. mysql-test/include/wait_for_slave_to_start.inc: Refactored to use wait_for_slave_param.inc. Removed connection slave. mysql-test/include/wait_for_slave_to_stop.inc: Refactored to use wait_for_slave_param.inc. Removed connection slave. mysql-test/include/wait_show_pattern.inc: Removed unused (and error-prone) file mysql-test/include/wait_slave_status.inc: Removed unused (and error-prone) file mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test: Renamed $keep_connection to $slave_keep_connection. mysql-test/suite/rpl/t/rpl_bug26395.test: Replace stop slave by stop_slave.inc mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test: Replace start/stop slave by start_slave.inc/stop_slave.inc. Replace wait_for_slave_param by wait_for_slave_sql_to_stop.inc. mysql-test/suite/rpl/t/rpl_dual_pos_advance.test: Renamed $keep_connection to $slave_keep_connection. mysql-test/suite/rpl/t/rpl_flushlog_loop.test: Replace wait_slave_status by start_slave.inc mysql-test/suite/rpl/t/rpl_idempotency.test: Added connection slave since wait_for_slave_sql_to_stop.inc does not do that any more. mysql-test/suite/rpl/t/rpl_incident.test: Replaced wait_for_slave_to_stop by wait_for_slave_sql_to_stop.inc mysql-test/suite/rpl/t/rpl_init_slave.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. Replaced save_master_pos;connection slave;sync_with_master by sync_slave_with_master. mysql-test/suite/rpl/t/rpl_log_pos.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. Replaced wait_for_slave_param by other wait_for_slave_* macros. mysql-test/suite/rpl/t/rpl_packet.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/suite/rpl/t/rpl_row_until.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. Replaced save_master_pos;connection slave;sync_with_master by sync_slave_with_master. mysql-test/suite/rpl/t/rpl_server_id1.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/suite/rpl/t/rpl_slave_grp_exec.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/suite/rpl/t/rpl_slave_skip.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/suite/rpl/t/rpl_slave_status.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/suite/rpl/t/rpl_sp.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/suite/rpl/t/rpl_sp_effects.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/suite/rpl/t/rpl_stm_until.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. Replaced save_master_pos;connection slave;sync_with_master by sync_slave_with_master. mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test: Replaced start slave by start_slave.inc. Added explicit connection slave since wait_for_slave_sql_to_stop.inc does not do that anymore. mysql-test/t/disabled.def: Disabled failing test. mysql-test/t/func_time.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/t/grant.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/t/grant2.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/t/innodb_notembedded.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/t/log_bin_trust_function_creators_func.test: Restore @@global.log_bin_trust_function_creators at end of test. Clean up at end of test by dropping the created user. mysql-test/t/query_cache.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/t/query_cache_notembedded.test: Restore @@global.log_bin_trust_function_creators at end of test. mysql-test/t/rpl_init_slave_func.test: Replaced start/stop slave by start_slave.inc/stop_slave.inc. mysql-test/t/timezone2.test: Restore @@global.log_bin_trust_function_creators at end of test.
299 lines
6.9 KiB
Text
299 lines
6.9 KiB
Text
source include/master-slave.inc;
|
|
source include/have_innodb.inc;
|
|
|
|
--echo **** On Slave ****
|
|
connection slave;
|
|
source include/have_innodb.inc;
|
|
STOP SLAVE;
|
|
|
|
--echo **** On Master ****
|
|
connection master;
|
|
SET SESSION BINLOG_FORMAT=ROW;
|
|
|
|
CREATE TABLE t1 (a INT, b INT);
|
|
CREATE TABLE t2 (c INT, d INT);
|
|
INSERT INTO t1 VALUES (1,1),(2,4),(3,9);
|
|
INSERT INTO t2 VALUES (1,1),(2,8),(3,27);
|
|
UPDATE t1,t2 SET b = d, d = b * 2 WHERE a = c;
|
|
source include/show_binlog_events.inc;
|
|
|
|
# These tables should be changed
|
|
SELECT * FROM t1;
|
|
SELECT * FROM t2;
|
|
save_master_pos;
|
|
|
|
--echo **** On Slave ****
|
|
connection slave;
|
|
|
|
# Stop when reaching the the first table map event.
|
|
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762;
|
|
wait_for_slave_to_stop;
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
|
|
query_vertical SHOW SLAVE STATUS;
|
|
|
|
# Now we skip *one* table map event. If the execution starts right
|
|
# after that table map event, *one* of the involved tables will be
|
|
# changed.
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
START SLAVE;
|
|
sync_with_master;
|
|
|
|
# These values should be what was inserted, not what was
|
|
# updated. Since we are skipping the first table map of the group
|
|
# representing the UPDATE statement above, we should skip the entire
|
|
# group and not start executing at the first table map.
|
|
SELECT * FROM t1;
|
|
SELECT * FROM t2;
|
|
|
|
STOP SLAVE;
|
|
RESET SLAVE;
|
|
connection master;
|
|
RESET MASTER;
|
|
|
|
SET SESSION BINLOG_FORMAT=STATEMENT;
|
|
SET @foo = 12;
|
|
INSERT INTO t1 VALUES(@foo, 2*@foo);
|
|
save_master_pos;
|
|
source include/show_binlog_events.inc;
|
|
|
|
connection slave;
|
|
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=106;
|
|
wait_for_slave_to_stop;
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
START SLAVE;
|
|
sync_with_master;
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
|
--replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
|
|
query_vertical SHOW SLAVE STATUS;
|
|
|
|
--echo **** On Master ****
|
|
connection master;
|
|
DROP TABLE t1, t2;
|
|
sync_slave_with_master;
|
|
|
|
#
|
|
# More tests for BUG#28618
|
|
#
|
|
# Case 1.
|
|
# ROW binlog format and non-transactional tables.
|
|
# Create the group of events via triggers and try to skip
|
|
# some items of that group.
|
|
#
|
|
|
|
connection master;
|
|
SET SESSION BINLOG_FORMAT=ROW;
|
|
SET AUTOCOMMIT=0;
|
|
|
|
CREATE TABLE t1 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
CREATE TABLE t2 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
CREATE TABLE t3 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
|
|
INSERT INTO t1 VALUES (1,'master/slave');
|
|
INSERT INTO t2 VALUES (1,'master/slave');
|
|
INSERT INTO t3 VALUES (1,'master/slave');
|
|
|
|
DELIMITER |;
|
|
|
|
CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW
|
|
BEGIN
|
|
INSERT INTO t2 VALUES (NEW.a,NEW.b);
|
|
DELETE FROM t2 WHERE a < NEW.a;
|
|
END|
|
|
|
|
CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW
|
|
BEGIN
|
|
UPDATE t3 SET a =2, b = 'master only';
|
|
END|
|
|
|
|
DELIMITER ;|
|
|
|
|
--echo **** On Slave ****
|
|
sync_slave_with_master;
|
|
source include/stop_slave.inc;
|
|
|
|
--echo **** On Master ****
|
|
connection master;
|
|
UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
|
|
DROP TRIGGER tr1;
|
|
DROP TRIGGER tr2;
|
|
INSERT INTO t1 VALUES (3,'master/slave');
|
|
INSERT INTO t2 VALUES (3,'master/slave');
|
|
INSERT INTO t3 VALUES (3,'master/slave');
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
SELECT * FROM t2 ORDER BY a;
|
|
SELECT * FROM t3 ORDER BY a;
|
|
|
|
save_master_pos;
|
|
|
|
--echo *** On Slave ***
|
|
connection slave;
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
source include/start_slave.inc;
|
|
sync_with_master;
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
SELECT * FROM t2 ORDER BY a;
|
|
SELECT * FROM t3 ORDER BY a;
|
|
|
|
connection master;
|
|
DROP TABLE t1, t2, t3;
|
|
sync_slave_with_master;
|
|
|
|
--echo **** Case 2: Row binlog format and transactional tables ****
|
|
|
|
# Create the transaction and try to skip some
|
|
# queries from one.
|
|
|
|
--echo *** On Master ***
|
|
connection master;
|
|
CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb;
|
|
CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
|
|
CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
|
|
|
|
--echo **** On Slave ****
|
|
sync_slave_with_master;
|
|
source include/stop_slave.inc;
|
|
|
|
--echo *** On Master ***
|
|
connection master;
|
|
BEGIN;
|
|
INSERT INTO t4 VALUES (2, 'master only');
|
|
INSERT INTO t5 VALUES (2, 'master only');
|
|
INSERT INTO t6 VALUES (2, 'master only');
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
INSERT INTO t4 VALUES (3, 'master/slave');
|
|
INSERT INTO t5 VALUES (3, 'master/slave');
|
|
INSERT INTO t6 VALUES (3, 'master/slave');
|
|
COMMIT;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
SELECT * FROM t5 ORDER BY a;
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
save_master_pos;
|
|
|
|
--echo *** On Slave ***
|
|
connection slave;
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
source include/start_slave.inc;
|
|
sync_with_master;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
SELECT * FROM t5 ORDER BY a;
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
# Test skipping two groups
|
|
|
|
--echo **** On Slave ****
|
|
connection slave;
|
|
source include/stop_slave.inc;
|
|
|
|
--echo *** On Master ***
|
|
connection master;
|
|
BEGIN;
|
|
INSERT INTO t4 VALUES (6, 'master only');
|
|
INSERT INTO t5 VALUES (6, 'master only');
|
|
INSERT INTO t6 VALUES (6, 'master only');
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
INSERT INTO t4 VALUES (7, 'master only');
|
|
INSERT INTO t5 VALUES (7, 'master only');
|
|
INSERT INTO t6 VALUES (7, 'master only');
|
|
COMMIT;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
SELECT * FROM t5 ORDER BY a;
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
save_master_pos;
|
|
|
|
--echo *** On Slave ***
|
|
connection slave;
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
|
|
source include/start_slave.inc;
|
|
sync_with_master;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
SELECT * FROM t5 ORDER BY a;
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
#
|
|
# And the same, but with autocommit = 0
|
|
#
|
|
connection slave;
|
|
source include/stop_slave.inc;
|
|
|
|
connection master;
|
|
SET AUTOCOMMIT=0;
|
|
|
|
INSERT INTO t4 VALUES (4, 'master only');
|
|
INSERT INTO t5 VALUES (4, 'master only');
|
|
INSERT INTO t6 VALUES (4, 'master only');
|
|
COMMIT;
|
|
|
|
INSERT INTO t4 VALUES (5, 'master/slave');
|
|
INSERT INTO t5 VALUES (5, 'master/slave');
|
|
INSERT INTO t6 VALUES (5, 'master/slave');
|
|
COMMIT;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
SELECT * FROM t5 ORDER BY a;
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
save_master_pos;
|
|
|
|
--echo *** On Slave ***
|
|
connection slave;
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
source include/start_slave.inc;
|
|
sync_with_master;
|
|
|
|
SELECT * FROM t4 ORDER BY a;
|
|
SELECT * FROM t5 ORDER BY a;
|
|
SELECT * FROM t6 ORDER BY a;
|
|
|
|
connection master;
|
|
DROP TABLE t4, t5, t6;
|
|
sync_slave_with_master;
|
|
|
|
--echo **** Case 3: Statement logging format and LOAD DATA with non-transactional table ****
|
|
|
|
# LOAD DATA creates two events in binary log for statement binlog format.
|
|
# Try to skip the first.
|
|
|
|
--echo *** On Master ***
|
|
connection master;
|
|
CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
|
|
|
|
--echo *** On Slave ***
|
|
sync_slave_with_master;
|
|
source include/stop_slave.inc;
|
|
|
|
--echo *** On Master ***
|
|
connection master;
|
|
SET SESSION BINLOG_FORMAT=STATEMENT;
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
|
|
|
|
SELECT * FROM t10 ORDER BY a;
|
|
|
|
save_master_pos;
|
|
|
|
--echo *** On Slave ***
|
|
connection slave;
|
|
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
|
source include/start_slave.inc;
|
|
sync_with_master;
|
|
|
|
SELECT * FROM t10 ORDER BY a;
|
|
|
|
connection master;
|
|
DROP TABLE t10;
|
|
sync_slave_with_master;
|
|
|