Debian Codegraph @

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

raw
1 #
2 # This test tests replaying a transaction with savepoint
3 #
4
5 --source include/galera_cluster.inc
6 --source include/have_innodb.inc
7 --source include/have_debug_sync.inc
8 --source include/galera_have_debug_sync.inc
9
10 --let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
11
12 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
13 INSERT INTO t1 VALUES (1, 'a');
14 INSERT INTO t1 VALUES (2, 'a');
15
16 --connection node_1
17 SET AUTOCOMMIT=ON;
18 START TRANSACTION;
19
20 UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
21 SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
22 SAVEPOINT my_sp;
23
24 # Block the applier on node #1 and issue a conflicting update on node #2
25 --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
26 SET SESSION wsrep_sync_wait=0;
27 --let $galera_sync_point = apply_monitor_slave_enter_sync
28 --source include/galera_set_sync_point.inc
29
30 --connection node_2
31 UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
32
33 --connection node_1a
34 --source include/galera_wait_sync_point.inc
35 --source include/galera_clear_sync_point.inc
36
37 # Block the commit, send the COMMIT and wait until it gets blocked
38
39 --let $galera_sync_point = commit_monitor_master_enter_sync
40 --source include/galera_set_sync_point.inc
41
42 --connection node_1
43 --send COMMIT
44
45 --connection node_1a
46
47 --let $galera_sync_point = apply_monitor_slave_enter_sync commit_monitor_master_enter_sync
48 --source include/galera_wait_sync_point.inc
49 --source include/galera_clear_sync_point.inc
50
51 # Let the conflicting UPDATE proceed and wait until it hits abort_trx_end.
52 # The victim transaction still sits in commit_monitor_master_sync_point.
53
54 --let $galera_sync_point = abort_trx_end
55 --source include/galera_set_sync_point.inc
56 --let $galera_sync_point = apply_monitor_slave_enter_sync
57 --source include/galera_signal_sync_point.inc
58 --let $galera_sync_point = abort_trx_end commit_monitor_master_enter_sync
59 --source include/galera_wait_sync_point.inc
60
61 # Let the transactions proceed
62 --source include/galera_clear_sync_point.inc
63 --let $galera_sync_point = abort_trx_end
64 --source include/galera_signal_sync_point.inc
65 --let $galera_sync_point = commit_monitor_master_enter_sync
66 --source include/galera_signal_sync_point.inc
67
68 # Commit succeeds
69 --connection node_1
70 --reap
71
72 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
73 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
74
75 # wsrep_local_replays has increased by 1
76 --let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
77 --disable_query_log
78 --eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays;
79 --enable_query_log
80
81 --connection node_2
82 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
83 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
84
85 DROP TABLE t1;