Debian Codegraph @

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

raw
1 #
2 # This test is a modified version of Gabor Orosz (GOro) test in jira tracker:
3 # https://jira.mariadb.org/browse/MDEV-25551
4 #
5 # The underlying problem with MDEV-25551 turned out to be that
6 # transactions having changes for tables with no primary key,
7 # were not safe to apply in parallel. This is due to excessive locking
8 # in innodb side, and even non related row modifications could end up
9 # in lock conflict during applying.
10 #
11 # The test creates a table with no primary key definition and executes two
12 # transactions (in node1) modifying separate rows in the table. In node2
13 # first applier is paused before commit phase, and second transaction is
14 # then submitted to see if it can interfere with the first transaciton.
15 # The fix for MDEV-25551 has disabled parallel applying for tables with no PK,
16 # and in the test applying of the send trasnaction should not even start, before
17 # the fisrt trkansaction is released from the sync point.
18 # The test also verifies that certification depedency status reflects the fact
19 # that the two transactions depend on each other.
20 #
21 # The test has two scenarios where both UPDATE and DELETE statements are verified
22 # to disable parallel applying
23 #
24
25 --source include/galera_cluster.inc
26 --source include/have_debug_sync.inc
27 --source include/galera_have_debug_sync.inc
28
29 # Setup
30
31 CREATE TABLE t1 (f1 VARCHAR(32) NOT NULL) ENGINE=InnoDB;
32 INSERT INTO t1 (f1) VALUES ('0e66c5227a8a');
33 INSERT INTO t1 (f1) VALUES ('c6c112992c9');
34
35 CREATE TABLE t2 (i int primary key);
36
37 --connection node_2
38 SET SESSION wsrep_sync_wait = 0;
39 --let $wait_condition = SELECT COUNT(*)=2 FROM t1;
40 --source include/wait_condition.inc
41
42 # Ensure that we have enough applier threads to process transactions in parallel
43 SET GLOBAL wsrep_slave_threads = 2;
44
45 --echo ***************************************************************
46 --echo scenario 1, conflicting UPDATE
47 --echo ***************************************************************
48
49 # Set up a synchronization point to catch the first transaction
50 --let $galera_sync_point = commit_monitor_slave_enter_sync
51 --source include/galera_set_sync_point.inc
52
53 --connection node_1
54 # Invoke the first transaction
55 START TRANSACTION;
56 UPDATE t1 SET f1='5ffceebfada' WHERE t1.f1 = 'c6c112992c9';
57 COMMIT;
58
59 --connection node_2
60 # Wait for the first transaction to apply until commit phase
61 --let $galera_sync_point = commit_monitor_slave_enter_sync
62 --source include/galera_wait_sync_point.inc
63
64 # remember status for received replication counter and certification dependency distance
65 --let $expected_wsrep_received = `SELECT VARIABLE_VALUE+1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_received'`
66 --let $cert_deps_distance = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'`
67
68 --connection node_1
69 # Invoke the second transaction
70 START TRANSACTION;
71 UPDATE t1 SET f1='4ffceebfcdc' WHERE t1.f1 = '0e66c5227a8a';
72 COMMIT;
73
74 # sleep is probably obsolete here, but it is good to give the latter update time to
75 # proceed in applying in node 2. In buggy version the update will start applying
76 # and cause conflict there.
77 --sleep 5
78
79 --connection node_2
80 # Wait for the second transaction to appear in repliaction queue
81 --let $wait_condition = SELECT VARIABLE_VALUE= $expected_wsrep_received FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_received';
82 --source include/wait_condition.inc
83
84 # verify that certification dependency distance has dropped
85 --disable_query_log
86 --eval SELECT VARIABLE_VALUE < $cert_deps_distance as 'distance' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'
87 --enable_query_log
88
89 # if deps distance dropped, it is indirect evidence that parallel applying was not approved
90
91 # Let the first transaction to proceed
92 --let $galera_sync_point = commit_monitor_slave_enter_sync
93 --source include/galera_signal_sync_point.inc
94
95 # second applier should now hit sync point
96 --let $galera_sync_point = commit_monitor_slave_enter_sync
97 --source include/galera_wait_sync_point.inc
98 --source include/galera_signal_sync_point.inc
99 --source include/galera_clear_sync_point.inc
100
101 --echo ***************************************************************
102 --echo scenario 2, conflicting DELETE
103 --echo ***************************************************************
104
105 # Set up a synchronization point to catch the first transaction
106 --let $galera_sync_point = commit_monitor_slave_enter_sync
107 --source include/galera_set_sync_point.inc
108
109 --connection node_1
110 # Invoke the first transaction, mix this with insert to table having PK
111 START TRANSACTION;
112 INSERT INTO t2 VALUES (1);
113 DELETE FROM t1 WHERE f1='5ffceebfada';
114 COMMIT;
115
116 --connection node_2
117 # Wait for the first transaction to apply until commit phase
118 --let $galera_sync_point = commit_monitor_slave_enter_sync
119 --source include/galera_wait_sync_point.inc
120
121 # remember status for received replication counter and certification dependency distance
122 --let $expected_wsrep_received = `SELECT VARIABLE_VALUE+1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_received'`
123 --let $cert_deps_distance = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'`
124
125 --connection node_1
126 # Invoke the second transaction, again mix this with insert to table having PK
127 START TRANSACTION;
128 INSERT INTO t2 VALUES (2);
129 DELETE FROM t1 WHERE f1='4ffceebfcdc';
130 COMMIT;
131
132 # sleep is probably obsolete here, but it is good to give the latter update time to
133 # proceed in applying in node 2. In buggy version the update will start applying
134 # and cause conflict there.
135 --sleep 5
136
137 --connection node_2
138 # Wait for the second transaction to appear in repliaction queue
139 --let $wait_condition = SELECT VARIABLE_VALUE= $expected_wsrep_received FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_received';
140 --source include/wait_condition.inc
141
142 # verify that certification dependency distance has dropped
143 --disable_query_log
144 --eval SELECT VARIABLE_VALUE < $cert_deps_distance as 'distance' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'
145 --enable_query_log
146
147 # if deps distance dropped, it is indirect evidence that parallel applying was not approved
148
149 # Let the first transaction to proceed
150 --let $galera_sync_point = commit_monitor_slave_enter_sync
151 --source include/galera_signal_sync_point.inc
152
153 # second applier should now hit sync point
154 --let $galera_sync_point = commit_monitor_slave_enter_sync
155 --source include/galera_wait_sync_point.inc
156 --source include/galera_signal_sync_point.inc
157 --source include/galera_clear_sync_point.inc
158
159 # Teardown
160 --connection node_1
161 SET GLOBAL wsrep_slave_threads = DEFAULT;
162
163 DROP TABLE t1;
164 DROP TABLE t2;
165
166 --connection node_2
167 SET GLOBAL wsrep_slave_threads = DEFAULT;