From 58c03e8f308c3f5e3a5c45b3af39529392569ba0 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 26 Apr 2018 12:56:24 +0200 Subject: [PATCH 1/3] MDEV-15794 Fix and re-enable test galera_var_retry_autocommit The test was not deterministic and would occasionally fail, due to the use of `sleep`. This patch is a complete rewrite of the test using proper sync points. --- mysql-test/suite/galera/disabled.def | 2 - .../r/galera_var_retry_autocommit.result | 78 +++++--- .../galera/t/galera_var_retry_autocommit.test | 169 +++++++++++------- sql/sql_parse.cc | 9 + 4 files changed, 165 insertions(+), 93 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 4c0a5c7fd9f..1b1d2b251ca 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -27,7 +27,5 @@ galera_ist_mysqldump : MDEV-13549 Galera test failures galera_ssl_upgrade : MDEV-13549 Galera test failures galera.MW-329 : wsrep_local_replays not stable galera.MW-328A : have_deadlocks test not stable -galera_var_retry_autocommit : MDEV-15794 Test failure on galera.galera_var_retry_autocommit galera_var_auto_inc_control_on : MDEV-15803 Test failure on galera.galera_var_auto_inc_control_on query_cache : MDEV-15805 Test failure on galera.query_cache - diff --git a/mysql-test/suite/galera/r/galera_var_retry_autocommit.result b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result index f4d17ad9a41..22a3105a588 100644 --- a/mysql-test/suite/galera/r/galera_var_retry_autocommit.result +++ b/mysql-test/suite/galera/r/galera_var_retry_autocommit.result @@ -1,32 +1,54 @@ -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; -CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; SET SESSION wsrep_retry_autocommit = 0; -INSERT INTO t1 (f1) VALUES (1),(2);; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +INSERT INTO t1 (f1) VALUES (2); +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; TRUNCATE TABLE t1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -SET SESSION wsrep_retry_autocommit = 1; -INSERT INTO t1 (f1) VALUES (3),(4);; -TRUNCATE TABLE t1; -SELECT * FROM test.t1; -f1 f2 -3 0 -4 0 -CREATE PROCEDURE repeated_truncate () -BEGIN -DECLARE i INT; -DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; -SET i = 0; -WHILE i <= 1000 DO -TRUNCATE TABLE t1; -SET i = i + 1; -END WHILE; -END| -CALL repeated_truncate(); -SET SESSION wsrep_retry_autocommit = 1; -INSERT INTO t1 (f1) VALUES (5),(6); -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -SET SESSION wsrep_retry_autocommit = 1024; -INSERT INTO t1 (f1) VALUES (7),(8);; -include/diff_servers.inc [servers=1 2] +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +SET SESSION wsrep_retry_autocommit = 1; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +INSERT INTO t1 (f1) VALUES (2); +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; +TRUNCATE TABLE t1; +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +SET SESSION wsrep_retry_autocommit = 1; +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 2'; +INSERT INTO t1 VALUES (2);; +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; +TRUNCATE TABLE t1; +SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue WAIT_FOR before_rep'; +TRUNCATE TABLE t1; +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; +DROP TABLE t1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +SET SESSION wsrep_retry_autocommit = 64; +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 64'; +INSERT INTO t1 VALUES (2); +SELECT COUNT(*) = 1 FROM t1; +COUNT(*) = 1 +1 +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; DROP TABLE t1; -DROP PROCEDURE repeated_truncate; diff --git a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test index bf4da3234c5..142f02546b4 100644 --- a/mysql-test/suite/galera/t/galera_var_retry_autocommit.test +++ b/mysql-test/suite/galera/t/galera_var_retry_autocommit.test @@ -1,98 +1,141 @@ # -# Test that the wsrep_retry_autocommit variable is respected. We use an INSERT that -# proceeds very slowly due to extra SLEEP() in a trigger +# Test that the wsrep_retry_autocommit variable is respected. # --source include/galera_cluster.inc --source include/have_innodb.inc +--source include/have_debug_sync.inc ---connection node_1 -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; -CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5); +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 # # With wsrep_retry_autocommit = 0, error is certain # --connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + SET SESSION wsrep_retry_autocommit = 0; ---send INSERT INTO t1 (f1) VALUES (1),(2); +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +--send INSERT INTO t1 (f1) VALUES (2) + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; --connection node_2 ---sleep 1 TRUNCATE TABLE t1; --connection node_1 --error ER_LOCK_DEADLOCK --reap +SELECT COUNT(*) = 0 FROM t1; + +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; + # # With wsrep_retry_autocommit = 1, success against one TRUNCATE # --connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + SET SESSION wsrep_retry_autocommit = 1; ---send INSERT INTO t1 (f1) VALUES (3),(4); +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; +--send INSERT INTO t1 (f1) VALUES (2) + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; --connection node_2 ---sleep 1 TRUNCATE TABLE t1; --connection node_1 ---error 0 --reap -SELECT * FROM test.t1; - -# -# With wsrep_retry_autocommit = 1, failure against multiple TRUNCATEs -# - ---connection node_2 -DELIMITER |; -CREATE PROCEDURE repeated_truncate () -BEGIN - DECLARE i INT; - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; - - SET i = 0; - WHILE i <= 1000 DO - TRUNCATE TABLE t1; - SET i = i + 1; - END WHILE; -END| -DELIMITER ;| - -# Begin streaming TRUNCATEs ---let $truncate_connection_id = `SELECT CONNECTION_ID()` ---send CALL repeated_truncate() - ---connection node_1 -SET SESSION wsrep_retry_autocommit = 1; ---sleep 1 ---error ER_LOCK_DEADLOCK -INSERT INTO t1 (f1) VALUES (5),(6); - -# -# With wsrep_retry_autocommit = 1024, success against multiple TRUNCATEs -# - ---connection node_1 -SET SESSION wsrep_retry_autocommit = 1024; ---send INSERT INTO t1 (f1) VALUES (7),(8); - ---sleep 6 - -# Once he stream of TRUNCATEs is complete ---connection node_2 ---reap - -# the INSERT will eventually be sucessfull ---connection node_1 ---error 0 ---reap - ---let $diff_servers = 1 2 ---source include/diff_servers.inc +SELECT COUNT(*) = 1 FROM t1; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; + + +# +# With wsrep_retry_autcommit = 1, failure against multiple TRUNCATEs +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +SET SESSION wsrep_retry_autocommit = 1; +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 2'; + +--send INSERT INTO t1 VALUES (2); + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; + +--connection node_2 +TRUNCATE TABLE t1; + +--connection node_1a +SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; +SELECT COUNT(*) = 0 FROM t1; +SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue WAIT_FOR before_rep'; + +--connection node_2 +TRUNCATE TABLE t1; + +--connection node_1a +SELECT COUNT(*) = 0 FROM t1; + +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; +DROP TABLE t1; + + +# +# With wsrep_retry_autocommit = 64, success against 64 TRUNCATEs +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +SET SESSION wsrep_retry_autocommit = 64; +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 64'; + +--send INSERT INTO t1 VALUES (2) + +--disable_query_log +--disable_result_log +--let $count = 64 +while ($count) +{ + --connection node_1a + SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; + + --connection node_2 + TRUNCATE TABLE t1; + + --connection node_1a + SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; + SELECT COUNT(*) = 1 FROM t1; + SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue'; + + --dec $count +} +--enable_result_log +--enable_query_log + +--connection node_1 +--reap +SELECT COUNT(*) = 1 FROM t1; + +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL debug_dbug = NULL; DROP TABLE t1; -DROP PROCEDURE repeated_truncate; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 352a1704ab7..9a1f877e4ed 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7187,6 +7187,15 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, com_statement_info[thd->get_command()].m_key); MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, thd->query(), thd->query_length()); + + DBUG_EXECUTE_IF("sync.wsrep_retry_autocommit", + { + const char act[]= + "now " + "SIGNAL wsrep_retry_autocommit_reached " + "WAIT_FOR wsrep_retry_autocommit_continue"; + DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); + }); } mysql_parse(thd, rawbuf, length, parser_state); From 9f9bce5f3e6adba82e8fd9818369ae1343eeff19 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 26 Apr 2018 13:58:31 +0200 Subject: [PATCH 2/3] MDEV-13549 Record and re-enable galera_ist_mysqldump Test works after fixes for galera_sst_mysqldump. --- mysql-test/suite/galera/disabled.def | 1 - mysql-test/suite/galera/r/galera_ist_mysqldump.result | 5 ++++- mysql-test/suite/galera/t/galera_ist_mysqldump.test | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 4c0a5c7fd9f..2128bbf17f9 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -23,7 +23,6 @@ galera_as_slave_replication_bundle : MDEV-13549 Galera test failures galera_gcache_recover : MDEV-13549 Galera test failures galera_gcache_recover_full_gcache : MDEV-13549 Galera test failures galera_gcache_recover_manytrx : MDEV-13549 Galera test failures -galera_ist_mysqldump : MDEV-13549 Galera test failures galera_ssl_upgrade : MDEV-13549 Galera test failures galera.MW-329 : wsrep_local_replays not stable galera.MW-328A : have_deadlocks test not stable diff --git a/mysql-test/suite/galera/r/galera_ist_mysqldump.result b/mysql-test/suite/galera/r/galera_ist_mysqldump.result index 788d60051b5..a7ce7c6c23e 100644 --- a/mysql-test/suite/galera/r/galera_ist_mysqldump.result +++ b/mysql-test/suite/galera/r/galera_ist_mysqldump.result @@ -1,4 +1,6 @@ Setting SST method to mysqldump ... +call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'"); +call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos"); CREATE USER 'sst'; GRANT ALL PRIVILEGES ON *.* TO 'sst'; SET GLOBAL wsrep_sst_auth = 'sst:'; @@ -194,7 +196,7 @@ INSERT INTO t1 VALUES ('node2_committed_before'); INSERT INTO t1 VALUES ('node2_committed_before'); INSERT INTO t1 VALUES ('node2_committed_before'); COMMIT; -SET GLOBAL debug = 'd,sync.alter_opened_table'; +SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ALTER TABLE t1 ADD COLUMN f2 INTEGER; SET wsrep_sync_wait = 0; Killing server ... @@ -273,6 +275,7 @@ COUNT(*) = 0 DROP TABLE t1; COMMIT; SET AUTOCOMMIT=ON; +SET GLOBAL debug_dbug = $debug_orig; CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); DROP USER sst; CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); diff --git a/mysql-test/suite/galera/t/galera_ist_mysqldump.test b/mysql-test/suite/galera/t/galera_ist_mysqldump.test index a9ff8c41f06..f60d5549eda 100644 --- a/mysql-test/suite/galera/t/galera_ist_mysqldump.test +++ b/mysql-test/suite/galera/t/galera_ist_mysqldump.test @@ -4,6 +4,10 @@ --source suite/galera/include/galera_sst_set_mysqldump.inc +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + # mysql-wsrep#33 - nnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno in trx_sys_update_wsrep_checkpoint with mysqldump IST # --source suite/galera/include/galera_st_disconnect_slave.inc @@ -14,4 +18,5 @@ --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc +--source include/auto_increment_offset_restore.inc --source suite/galera/include/galera_sst_restore.inc From b8d4ae08382bc79a82f298bdc6117a6e20a39fe3 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 27 Apr 2018 12:02:23 +0200 Subject: [PATCH 3/3] Save / restore auto_increment_offset in test galera_gcs_fragment Test galera_gcs_fragment performs cluster reconfiguration, so `auto_increment_offset` may change, and check test case at the end of test fails. --- mysql-test/suite/galera/t/galera_gcs_fragment.test | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysql-test/suite/galera/t/galera_gcs_fragment.test b/mysql-test/suite/galera/t/galera_gcs_fragment.test index 0436e312f6e..80d3a5cb659 100644 --- a/mysql-test/suite/galera/t/galera_gcs_fragment.test +++ b/mysql-test/suite/galera/t/galera_gcs_fragment.test @@ -3,6 +3,11 @@ --source include/have_innodb.inc --source suite/galera/include/galera_have_debug_sync.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + # Prepare table CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 TEXT); @@ -65,3 +70,5 @@ SELECT * FROM t1; --connection node_1 DROP TABLE t1; + +--source include/auto_increment_offset_restore.inc