mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
Major replication test framework cleanup. This does the following: - Ensure that all tests clean up the replication state when they finish, by making check-testcase check the output of SHOW SLAVE STATUS. This implies: - Slave must not be running after test finished. This is good because it removes the risk for sporadic errors in subsequent tests when a test forgets to sync correctly. - Slave SQL and IO errors must be cleared when test ends. This is good because we will notice if a test gets an unexpected error in the slave threads near the end. - We no longer have to clean up before a test starts. - Ensure that all tests that wait for an error in one of the slave threads waits for a specific error. It is no longer possible to source wait_for_slave_[sql|io]_to_stop.inc when there is an error in one of the slave threads. This is good because: - If a test expects an error but there is a bug that causes another error to happen, or if it stops the slave thread without an error, then we will notice. - When developing tests, wait_for_*_to_[start|stop].inc will fail immediately if there is an error in the relevant slave thread. Before this patch, we had to wait for the timeout. - Remove duplicated and repeated code for setting up unusual replication topologies. Now, there is a single file that is capable of setting up arbitrary topologies (include/rpl_init.inc, but include/master-slave.inc is still available for the most common topology). Tests can now end with include/rpl_end.inc, which will clean up correctly no matter what topology is used. The topology can be changed with include/rpl_change_topology.inc. - Improved debug information when tests fail. This includes: - debug info is printed on all servers configured by include/rpl_init.inc - User can set $rpl_debug=1, which makes auxiliary replication files print relevant debug info. - Improved documentation for all auxiliary replication files. Now they describe purpose, usage, parameters, and side effects. - Many small code cleanups: - Made have_innodb.inc output a sensible error message. - Moved contents of rpl000017-slave.sh into rpl000017.test - Added mysqltest variables that expose the current state of disable_warnings/enable_warnings and friends. - Too many to list here: see per-file comments for details.
110 lines
4.5 KiB
Plaintext
110 lines
4.5 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
==== Initialize ====
|
|
[on master]
|
|
CREATE TABLE t1 (a CHAR(48));
|
|
CREATE TEMPORARY TABLE t1_tmp1(a INT);
|
|
INSERT INTO t1 VALUES (UUID());
|
|
[on slave]
|
|
==== Verify results on slave ====
|
|
SHOW STATUS LIKE "Slave_open_temp_tables";
|
|
Variable_name Value
|
|
Slave_open_temp_tables 1
|
|
[on master]
|
|
[on master1]
|
|
[on slave]
|
|
==== Verify results on slave ====
|
|
SHOW STATUS LIKE "Slave_open_temp_tables";
|
|
Variable_name Value
|
|
Slave_open_temp_tables 0
|
|
==== Clean up ====
|
|
[on master]
|
|
include/rpl_connect.inc [creating master]
|
|
DROP TABLE t1;
|
|
[on slave]
|
|
include/rpl_reset.inc
|
|
CREATE TABLE t1 (a int);
|
|
CREATE TABLE t2 ( i1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (i1) );
|
|
CREATE TABLE t3 ( i1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (i1) );
|
|
CREATE TRIGGER tr1 AFTER DELETE ON t2 FOR EACH ROW INSERT INTO t3 () VALUES ();
|
|
CREATE TEMPORARY TABLE t1_tmp (i1 int);
|
|
ALTER TABLE t1_tmp ADD COLUMN b INT;
|
|
DELETE FROM t2;
|
|
CREATE TEMPORARY TABLE t2_tmp (a int);
|
|
ALTER TABLE t1_tmp ADD COLUMN c INT;
|
|
### assertion: assert that there is one open temp table on slave
|
|
SHOW STATUS LIKE 'Slave_open_temp_tables';
|
|
Variable_name Value
|
|
Slave_open_temp_tables 1
|
|
DROP TABLE t1_tmp, t2;
|
|
INSERT INTO t1 VALUES (1);
|
|
DROP TEMPORARY TABLE t2_tmp;
|
|
INSERT INTO t1 VALUES (2);
|
|
### assertion: assert that slave has no temporary tables opened
|
|
SHOW STATUS LIKE 'Slave_open_temp_tables';
|
|
Variable_name Value
|
|
Slave_open_temp_tables 0
|
|
DROP TABLE t3, t1;
|
|
show binlog events from <binlog_start>;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a int)
|
|
slave-bin.000001 # Query # # use `test`; CREATE TABLE t2 ( i1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (i1) )
|
|
slave-bin.000001 # Query # # use `test`; CREATE TABLE t3 ( i1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (i1) )
|
|
slave-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER tr1 AFTER DELETE ON t2 FOR EACH ROW INSERT INTO t3 () VALUES ()
|
|
slave-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE t1_tmp (i1 int)
|
|
slave-bin.000001 # Query # # use `test`; ALTER TABLE t1_tmp ADD COLUMN b INT
|
|
slave-bin.000001 # Query # # use `test`; DROP TABLE `t2` /* generated by server */
|
|
slave-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `t1_tmp` /* generated by server */
|
|
slave-bin.000001 # Query # # BEGIN
|
|
slave-bin.000001 # Table_map # # table_id: # (test.t1)
|
|
slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
|
slave-bin.000001 # Query # # COMMIT
|
|
slave-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `t2_tmp` /* generated by server */
|
|
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
|
|
slave-bin.000001 # Query # # use `test`; DROP TABLE t3, t1
|
|
|
|
# Bug#55478 Row events wrongly apply on the temporary table of the same name
|
|
# ==========================================================================
|
|
# The statement should be binlogged
|
|
CREATE TEMPORARY TABLE t1(c1 INT) ENGINE=InnoDB;
|
|
|
|
# Case 1: CREATE TABLE t1 ... SELECT
|
|
# ----------------------------------
|
|
|
|
# The statement generates row events on t1. And the rows events should
|
|
# be inserted into the base table on slave.
|
|
CREATE TABLE t1 ENGINE=MyISAM SELECT rand();
|
|
show binlog events in 'master-bin.000001' from <binlog_start>;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 # Query # # BEGIN
|
|
master-bin.000001 # Query # # use `test`; CREATE TABLE `t1` (
|
|
`rand()` double NOT NULL DEFAULT '0'
|
|
) ENGINE=MyISAM
|
|
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
|
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
|
master-bin.000001 # Query # # COMMIT
|
|
|
|
# Case 2: DROP TEMPORARY TABLE in a transacation(happens only on 5.5+)
|
|
# --------------------------------------------------------------------
|
|
|
|
BEGIN;
|
|
DROP TEMPORARY TABLE t1;
|
|
# The statement will binlogged after 'DROP TEMPORARY TABLE t1'
|
|
INSERT INTO t1 VALUES(1);
|
|
# The rows event will binlogged after 'INSERT INTO t1 VALUES(1)'
|
|
INSERT INTO t1 VALUES(Rand());
|
|
COMMIT;
|
|
show binlog events in 'master-bin.000001' from <binlog_start>;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `t1` /* generated by server */
|
|
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(1)
|
|
master-bin.000001 # Query # # BEGIN
|
|
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
|
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
|
master-bin.000001 # Query # # COMMIT
|
|
# Compare the base table.
|
|
include/diff_tables.inc [master:t1, slave:t1]
|
|
|
|
DROP TABLE t1;
|
|
include/rpl_end.inc
|