|
1 | 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 |
| 2 | +# Test that the wsrep_retry_autocommit variable is respected. |
4 | 3 | #
|
5 | 4 |
|
6 | 5 | --source include/galera_cluster.inc
|
7 | 6 | --source include/have_innodb.inc
|
| 7 | +--source include/have_debug_sync.inc |
8 | 8 |
|
9 |
| ---connection node_1 |
10 |
| -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; |
11 |
| -CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f2 = SLEEP(5); |
| 9 | +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
12 | 10 |
|
13 | 11 | #
|
14 | 12 | # With wsrep_retry_autocommit = 0, error is certain
|
15 | 13 | #
|
16 | 14 |
|
17 | 15 | --connection node_1
|
| 16 | +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
| 17 | + |
18 | 18 | SET SESSION wsrep_retry_autocommit = 0;
|
19 |
| ---send INSERT INTO t1 (f1) VALUES (1),(2); |
| 19 | +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; |
| 20 | +--send INSERT INTO t1 (f1) VALUES (2) |
| 21 | + |
| 22 | +--connection node_1a |
| 23 | +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; |
20 | 24 |
|
21 | 25 | --connection node_2
|
22 |
| ---sleep 1 |
23 | 26 | TRUNCATE TABLE t1;
|
24 | 27 |
|
25 | 28 | --connection node_1
|
26 | 29 | --error ER_LOCK_DEADLOCK
|
27 | 30 | --reap
|
| 31 | +SELECT COUNT(*) = 0 FROM t1; |
| 32 | + |
| 33 | +SET DEBUG_SYNC = 'RESET'; |
| 34 | +DROP TABLE t1; |
| 35 | + |
28 | 36 |
|
29 | 37 | #
|
30 | 38 | # With wsrep_retry_autocommit = 1, success against one TRUNCATE
|
31 | 39 | #
|
32 | 40 |
|
33 | 41 | --connection node_1
|
| 42 | +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
| 43 | + |
34 | 44 | SET SESSION wsrep_retry_autocommit = 1;
|
35 |
| ---send INSERT INTO t1 (f1) VALUES (3),(4); |
| 45 | +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue'; |
| 46 | +--send INSERT INTO t1 (f1) VALUES (2) |
| 47 | + |
| 48 | +--connection node_1a |
| 49 | +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; |
36 | 50 |
|
37 | 51 | --connection node_2
|
38 |
| ---sleep 1 |
39 | 52 | TRUNCATE TABLE t1;
|
40 | 53 |
|
41 | 54 | --connection node_1
|
42 |
| ---error 0 |
43 | 55 | --reap
|
44 |
| -SELECT * FROM test.t1; |
| 56 | +SELECT COUNT(*) = 1 FROM t1; |
| 57 | + |
| 58 | +SET DEBUG_SYNC = 'RESET'; |
| 59 | +DROP TABLE t1; |
| 60 | + |
45 | 61 |
|
46 | 62 | #
|
47 |
| -# With wsrep_retry_autocommit = 1, failure against multiple TRUNCATEs |
| 63 | +# With wsrep_retry_autcommit = 1, failure against multiple TRUNCATEs |
48 | 64 | #
|
49 | 65 |
|
| 66 | +--connection node_1 |
| 67 | +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
| 68 | + |
| 69 | +SET SESSION wsrep_retry_autocommit = 1; |
| 70 | +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; |
| 71 | +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 2'; |
| 72 | + |
| 73 | +--send INSERT INTO t1 VALUES (2); |
| 74 | + |
| 75 | +--connection node_1a |
| 76 | +SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; |
| 77 | + |
50 | 78 | --connection node_2
|
51 |
| -DELIMITER |; |
52 |
| -CREATE PROCEDURE repeated_truncate () |
53 |
| -BEGIN |
54 |
| - DECLARE i INT; |
55 |
| - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; |
56 |
| - |
57 |
| - SET i = 0; |
58 |
| - WHILE i <= 1000 DO |
59 |
| - TRUNCATE TABLE t1; |
60 |
| - SET i = i + 1; |
61 |
| - END WHILE; |
62 |
| -END| |
63 |
| -DELIMITER ;| |
64 |
| - |
65 |
| -# Begin streaming TRUNCATEs |
66 |
| ---let $truncate_connection_id = `SELECT CONNECTION_ID()` |
67 |
| ---send CALL repeated_truncate() |
| 79 | +TRUNCATE TABLE t1; |
| 80 | + |
| 81 | +--connection node_1a |
| 82 | +SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; |
| 83 | +SELECT COUNT(*) = 0 FROM t1; |
| 84 | +SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue WAIT_FOR before_rep'; |
| 85 | + |
| 86 | +--connection node_2 |
| 87 | +TRUNCATE TABLE t1; |
| 88 | + |
| 89 | +--connection node_1a |
| 90 | +SELECT COUNT(*) = 0 FROM t1; |
68 | 91 |
|
69 | 92 | --connection node_1
|
70 |
| -SET SESSION wsrep_retry_autocommit = 1; |
71 |
| ---sleep 1 |
72 | 93 | --error ER_LOCK_DEADLOCK
|
73 |
| -INSERT INTO t1 (f1) VALUES (5),(6); |
| 94 | +--reap |
| 95 | + |
| 96 | +SET DEBUG_SYNC = 'RESET'; |
| 97 | +SET GLOBAL debug_dbug = NULL; |
| 98 | +DROP TABLE t1; |
| 99 | + |
74 | 100 |
|
75 | 101 | #
|
76 |
| -# With wsrep_retry_autocommit = 1024, success against multiple TRUNCATEs |
| 102 | +# With wsrep_retry_autocommit = 64, success against 64 TRUNCATEs |
77 | 103 | #
|
78 | 104 |
|
79 | 105 | --connection node_1
|
80 |
| -SET SESSION wsrep_retry_autocommit = 1024; |
81 |
| ---send INSERT INTO t1 (f1) VALUES (7),(8); |
| 106 | +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
82 | 107 |
|
83 |
| ---sleep 6 |
| 108 | +SET SESSION wsrep_retry_autocommit = 64; |
| 109 | +SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit'; |
| 110 | +SET DEBUG_SYNC = 'wsrep_before_replication SIGNAL before_rep WAIT_FOR continue EXECUTE 64'; |
84 | 111 |
|
85 |
| -# Once he stream of TRUNCATEs is complete |
86 |
| ---connection node_2 |
87 |
| ---reap |
| 112 | +--send INSERT INTO t1 VALUES (2) |
| 113 | + |
| 114 | +--disable_query_log |
| 115 | +--disable_result_log |
| 116 | +--let $count = 64 |
| 117 | +while ($count) |
| 118 | +{ |
| 119 | + --connection node_1a |
| 120 | + SET DEBUG_SYNC = 'now WAIT_FOR before_rep'; |
| 121 | + |
| 122 | + --connection node_2 |
| 123 | + TRUNCATE TABLE t1; |
| 124 | + |
| 125 | + --connection node_1a |
| 126 | + SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached'; |
| 127 | + SELECT COUNT(*) = 1 FROM t1; |
| 128 | + SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue'; |
| 129 | + |
| 130 | + --dec $count |
| 131 | +} |
| 132 | +--enable_result_log |
| 133 | +--enable_query_log |
88 | 134 |
|
89 |
| -# the INSERT will eventually be sucessfull |
90 | 135 | --connection node_1
|
91 |
| ---error 0 |
92 | 136 | --reap
|
| 137 | +SELECT COUNT(*) = 1 FROM t1; |
93 | 138 |
|
94 |
| ---let $diff_servers = 1 2 |
95 |
| ---source include/diff_servers.inc |
96 |
| - |
| 139 | +SET DEBUG_SYNC = 'RESET'; |
| 140 | +SET GLOBAL debug_dbug = NULL; |
97 | 141 | DROP TABLE t1;
|
98 |
| -DROP PROCEDURE repeated_truncate; |
|
0 commit comments