Debian Codegraph @

mysql-test/suite/galera_sr/t/galera_sr_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 verifies that a transaction executing a streaming replication
12 # will disable parallel applying if it modifies a table with no primary key.
13 # And, if PA was disabled temporarily, it will be relaxed if next fragment
14 # contains changes for table with primary key.
15 #
16
17 --source include/galera_cluster.inc
18 --source include/have_debug_sync.inc
19 --source include/galera_have_debug_sync.inc
20
21
22 # Setup
23 --connection node_2
24 SET SESSION wsrep_sync_wait = 0;
25
26 # Ensure that we have enough applier threads to process transactions in parallel
27 SET GLOBAL wsrep_slave_threads = 2;
28
29 flush status;
30
31 --connection node_1
32 CREATE TABLE t1 (f1 int, f2 int) ENGINE=InnoDB;
33 CREATE TABLE t2 (f1 int primary key, f2 int) ENGINE=InnoDB;
34 INSERT INTO t1 VALUES (1,0);
35 INSERT INTO t1 VALUES (2,0);
36
37 INSERT INTO t2 VALUES (1,0);
38 INSERT INTO t2 VALUES (2,0);
39
40 --connection node_2
41 --let $wait_condition = SELECT COUNT(*)=2 FROM t2;
42 --source include/wait_condition.inc
43
44 # remember status for received replication counter and certification dependency distance
45 --let $cert_deps_distance = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'`
46
47 --connection node_1
48 # Invoke the first transaction
49 set session wsrep_trx_fragment_size=1;
50 START TRANSACTION;
51 UPDATE t1 SET f2=1 where f1=1;
52
53 --connection node_2
54 # verify that certification dependency distance has dropped
55 --disable_query_log
56 --eval SELECT VARIABLE_VALUE < $cert_deps_distance as 'distance' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'
57 --enable_query_log
58
59 # if deps distance dropped, it is indirect evidence that parallel applying was not approved
60
61 # Try next that PA retricting is relaxed, if next fragment updates table t1 with primary key
62 # wsrep_cert_deps_distance cannot be trsuted in this test phase, we verify parallel applying
63 # by setting sync point for applier thread
64
65 # Set up a synchronization point to catch update on t2
66 --let $galera_sync_point = commit_monitor_slave_enter_sync
67 --source include/galera_set_sync_point.inc
68
69 --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
70 --connection node_1a
71 update t2 set f2=1 where f1=1;
72
73 --connection node_2
74 # Wait for the update t2 to apply until commit phase
75 --let $galera_sync_point = commit_monitor_slave_enter_sync
76 --source include/galera_wait_sync_point.inc
77
78 # Set up a synchronization point to catch the SR trx applying
79 --let $galera_sync_point = apply_monitor_slave_enter_sync
80 --source include/galera_set_sync_point.inc
81
82 --connection node_1
83 # continue SR transaction, and now update t2, which has PK
84 UPDATE t2 set f2=2 where f1=2;
85
86 --connection node_2
87 # Wait for the update t2 to apply until commit phase
88 --let $galera_sync_point = apply_monitor_slave_enter_sync commit_monitor_slave_enter_sync
89 --source include/galera_wait_sync_point.inc
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 --source include/galera_clear_sync_point.inc
95 --let $galera_sync_point = apply_monitor_slave_enter_sync
96 --source include/galera_signal_sync_point.inc
97 --source include/galera_clear_sync_point.inc
98
99 --connection node_1
100 COMMIT;
101
102 # Teardown
103 --connection node_1
104 SET GLOBAL wsrep_slave_threads = DEFAULT;
105
106 DROP TABLE t1;
107 DROP TABLE t2;
108 --connection node_2
109 SET GLOBAL wsrep_slave_threads = DEFAULT;