Skip to content

Commit 9b13147

Browse files
Galera MTR Tests: MW-308 , MW-307, GCF-992
* a dedicated test for wsrep_retry_autocommit * some galera_toi_* tests were only passing because wsrep_retry_autocommit was in effect. The tests were changed to do not use autocommit * higher timeout values in galera_2nodes.cnf , galera_3nodes.cnf Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
1 parent 09d8fbc commit 9b13147

11 files changed

+168
-140
lines changed

mysql-test/suite/galera/galera_2nodes.cnf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port'
2525
#ist_port=@OPT.port
2626
#sst_port=@OPT.port
2727
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
28-
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;gcache.size=10M;evs.suspect_timeout=PT10S'
28+
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S'
29+
30+
# enforce read-committed characteristics across the cluster
31+
wsrep_causal_reads=ON
32+
wsrep_sync_wait = 7
33+
34+
wsrep_node_address=127.0.0.1
35+
wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
2936
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
3037
wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
3138

mysql-test/suite/galera/r/galera_defaults.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ WSREP_SST_DONOR
5050
WSREP_SST_DONOR_REJECTS_QUERIES OFF
5151
WSREP_SST_METHOD rsync
5252
WSREP_SYNC_WAIT 7
53-
<BASE_DIR>; <BASE_HOST>; <BASE_PORT>; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; <GCACHE_DIR>; gcache.keep_pages_size = 0; gcache.mem_size = 0; <GCACHE_NAME>; gcache.page_size = 128M; gcache.size = 10M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; <GCS_RECV_Q_HARD_LIMIT>; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; <GMCAST_LISTEN_ADDR>; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; <IST_RECV_ADDR>; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992;
53+
<BASE_DIR>; <BASE_HOST>; <BASE_PORT>; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT30S; evs.info_log_mask = 0; evs.install_timeout = PT15S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT10S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; <GCACHE_DIR>; gcache.keep_pages_size = 0; gcache.mem_size = 0; <GCACHE_NAME>; gcache.page_size = 128M; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; <RECV_Q_HARD_LIMIT>;gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; <GMCAST_LISTEN_ADDR>; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; <IST_RECV_ADDR>; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT90S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992;
5454
SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS
5555
WHERE VARIABLE_NAME LIKE 'wsrep_%'
5656
AND VARIABLE_NAME != 'wsrep_debug_sync_waiters';

mysql-test/suite/galera/r/galera_toi_ddl_online.result

Lines changed: 0 additions & 27 deletions
This file was deleted.

mysql-test/suite/galera/r/galera_toi_drop_database.result

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
44
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
55
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
66
CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
7+
SET SESSION wsrep_retry_autocommit = 0;
78
INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;;
89
USE database1;
10+
SET SESSION wsrep_retry_autocommit = 0;
911
INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;;
1012
DROP DATABASE database1;;
11-
ERROR 42S02: Table 'database1.t1' doesn't exist
12-
ERROR 42S02: Table 'database1.t2' doesn't exist
13+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
14+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
1315
SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database1';
1416
COUNT(*) = 0
1517
1
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
22
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
33
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
4+
SET SESSION wsrep_retry_autocommit = 0;
45
INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
56
TRUNCATE TABLE t1;;
6-
SELECT COUNT(*) = 1000000 FROM t1;
7-
COUNT(*) = 1000000
7+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
8+
SELECT COUNT(*) = 0 FROM t1;
9+
COUNT(*) = 0
810
1
9-
DROP TABLE t1;
10-
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
11-
INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;;
12-
TRUNCATE TABLE t1;;
13-
SELECT COUNT(*) = 1000000 FROM t1;
14-
COUNT(*) = 1000000
11+
SELECT COUNT(*) = 0 FROM t1;
12+
COUNT(*) = 0
1513
1
1614
DROP TABLE t1;
1715
DROP TABLE ten;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
2+
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5);
3+
SET SESSION wsrep_retry_autocommit = 0;
4+
INSERT INTO t1 (f1) VALUES (1),(2);;
5+
TRUNCATE TABLE t1;
6+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
7+
SET SESSION wsrep_retry_autocommit = 1;
8+
INSERT INTO t1 (f1) VALUES (3),(4);;
9+
TRUNCATE TABLE t1;
10+
SELECT * FROM test.t1;
11+
f1 f2
12+
3 0
13+
4 0
14+
CREATE PROCEDURE repeated_truncate ()
15+
BEGIN
16+
DECLARE i INT;
17+
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
18+
SET i = 0;
19+
WHILE i <= 1000 DO
20+
TRUNCATE TABLE t1;
21+
SET i = i + 1;
22+
END WHILE;
23+
END|
24+
CALL repeated_truncate();
25+
SET SESSION wsrep_retry_autocommit = 1;
26+
INSERT INTO t1 (f1) VALUES (5),(6);
27+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
28+
SET SESSION wsrep_retry_autocommit = 1024;
29+
INSERT INTO t1 (f1) VALUES (7),(8);;
30+
include/diff_servers.inc [servers=1 2]
31+
DROP TABLE t1;
32+
DROP PROCEDURE repeated_truncate;

mysql-test/suite/galera/t/galera_toi_ddl_online.test

Lines changed: 0 additions & 53 deletions
This file was deleted.

mysql-test/suite/galera/t/galera_toi_drop_database.test

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Test the operation of DDLs that affect multiple database objects
33
#
44

5-
--source include/big_test.inc
65
--source include/galera_cluster.inc
76
--source include/have_innodb.inc
87

@@ -20,24 +19,27 @@ INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
2019
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
2120
CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
2221

23-
# Insert 1M rows
22+
# Make sure autocommit retrying does not kick in as this will mask the error we expect to get
23+
SET SESSION wsrep_retry_autocommit = 0;
24+
# Attemp to insert 1M rows
2425
--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
2526

2627
--connection node_1a
2728
USE database1;
29+
SET SESSION wsrep_retry_autocommit = 0;
2830
--send INSERT INTO t2 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
2931

3032
--connection node_2
3133
--sleep 1
3234
--send DROP DATABASE database1;
3335

3436
--connection node_1
35-
--sleep 30
36-
--error ER_NO_SUCH_TABLE
37+
--sleep 1
38+
--error ER_LOCK_DEADLOCK
3739
--reap
3840

3941
--connection node_1a
40-
--error ER_NO_SUCH_TABLE
42+
--error ER_LOCK_DEADLOCK
4143
--reap
4244

4345
--connection node_2
Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#
2-
# Test the operation of TRUNCATE with concurrent DML. Even in the face of a concurrent INSERT,
3-
# the TRUNCATE will complete first and be recorded in the history before the INSERT.
2+
# Test the operation of TRUNCATE with concurrent DML.
3+
# The DML should be BF-aborted if the DDL arrives from another node
44
#
55

6-
--source include/big_test.inc
76
--source include/galera_cluster.inc
87
--source include/have_innodb.inc
98

@@ -19,6 +18,8 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
1918

2019
# Insert 100K rows
2120
--connection node_2
21+
# Prevent autocommit retring from masking the deadlock error we expect to get
22+
SET SESSION wsrep_retry_autocommit = 0;
2223
--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
2324

2425
--connection node_1
@@ -29,49 +30,14 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
2930
--reap
3031

3132
--connection node_2
33+
--error ER_LOCK_DEADLOCK
3234
--reap
3335

3436
--connection node_2
35-
SELECT COUNT(*) = 1000000 FROM t1;
37+
SELECT COUNT(*) = 0 FROM t1;
3638

3739
--connection node_1
38-
--let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1;
39-
--source include/wait_condition.inc
40-
41-
DROP TABLE t1;
42-
43-
#
44-
# INSERT AND TRUNCATE on same node
45-
#
46-
47-
--let $galera_connection_name = node_1a
48-
--let $galera_server_number = 1
49-
--source include/galera_connect.inc
50-
51-
--connection node_1
52-
53-
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
54-
55-
# Insert 100K rows
56-
--connection node_1
57-
--send INSERT INTO t1 (f1) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6;
58-
59-
--connection node_1a
60-
--sleep 1
61-
--send TRUNCATE TABLE t1;
62-
63-
--connection node_1
64-
--reap
65-
66-
--connection node_1a
67-
--reap
68-
69-
--connection node_1
70-
SELECT COUNT(*) = 1000000 FROM t1;
71-
72-
--connection node_2
73-
--let $wait_condition = SELECT COUNT(*) = 1000000 FROM t1;
74-
--source include/wait_condition.inc
40+
SELECT COUNT(*) = 0 FROM t1;
7541

7642
DROP TABLE t1;
7743
DROP TABLE ten;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#
2+
# Test that the wsrep_retry_autocommit variable is respected. We use an INSERT that
3+
# proceeds very slowly due to extra SLEEP() in a trigger
4+
#
5+
6+
--source include/galera_cluster.inc
7+
8+
--connection node_1
9+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
10+
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5);
11+
12+
#
13+
# With wsrep_retry_autocommit = 0, error is certain
14+
#
15+
16+
--connection node_1
17+
SET SESSION wsrep_retry_autocommit = 0;
18+
--send INSERT INTO t1 (f1) VALUES (1),(2);
19+
20+
--connection node_2
21+
--sleep 1
22+
TRUNCATE TABLE t1;
23+
24+
--connection node_1
25+
--error ER_LOCK_DEADLOCK
26+
--reap
27+
28+
#
29+
# With wsrep_retry_autocommit = 1, success against one TRUNCATE
30+
#
31+
32+
--connection node_1
33+
SET SESSION wsrep_retry_autocommit = 1;
34+
--send INSERT INTO t1 (f1) VALUES (3),(4);
35+
36+
--connection node_2
37+
--sleep 1
38+
TRUNCATE TABLE t1;
39+
40+
--connection node_1
41+
--error 0
42+
--reap
43+
SELECT * FROM test.t1;
44+
45+
#
46+
# With wsrep_retry_autocommit = 1, failure against multiple TRUNCATEs
47+
#
48+
49+
--connection node_2
50+
DELIMITER |;
51+
CREATE PROCEDURE repeated_truncate ()
52+
BEGIN
53+
DECLARE i INT;
54+
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
55+
56+
SET i = 0;
57+
WHILE i <= 1000 DO
58+
TRUNCATE TABLE t1;
59+
SET i = i + 1;
60+
END WHILE;
61+
END|
62+
DELIMITER ;|
63+
64+
# Begin streaming TRUNCATEs
65+
--let $truncate_connection_id = `SELECT CONNECTION_ID()`
66+
--send CALL repeated_truncate()
67+
68+
--connection node_1
69+
SET SESSION wsrep_retry_autocommit = 1;
70+
--sleep 1
71+
--error ER_LOCK_DEADLOCK
72+
INSERT INTO t1 (f1) VALUES (5),(6);
73+
74+
#
75+
# With wsrep_retry_autocommit = 1024, success against multiple TRUNCATEs
76+
#
77+
78+
--connection node_1
79+
SET SESSION wsrep_retry_autocommit = 1024;
80+
--send INSERT INTO t1 (f1) VALUES (7),(8);
81+
82+
--sleep 6
83+
84+
# Once he stream of TRUNCATEs is complete
85+
--connection node_2
86+
--reap
87+
88+
# the INSERT will eventually be sucessfull
89+
--connection node_1
90+
--error 0
91+
--reap
92+
93+
--let $diff_servers = 1 2
94+
--source include/diff_servers.inc
95+
96+
DROP TABLE t1;
97+
DROP PROCEDURE repeated_truncate;

0 commit comments

Comments
 (0)