Debian Codegraph @

mysql-test/suite/galera/t/MW-292.test

raw
1 #
2 # MW-292 Reset timestamp after transaction replay
3 #
4 # We force transaction replay to happen and then we check that NOW() is not stuck in time.
5 # As a bonus we also check that RAND() continues to return random values after replay
6 #
7 #
8
9 --source include/galera_cluster.inc
10 --source include/have_innodb.inc
11 --source include/have_debug_sync.inc
12 --source include/galera_have_debug_sync.inc
13
14 --let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
15
16 CREATE TABLE rand_table (f1 FLOAT);
17 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
18 INSERT INTO t1 VALUES (1, 'a');
19 INSERT INTO t1 VALUES (2, 'a');
20
21 --connection node_1
22 SET AUTOCOMMIT=ON;
23 START TRANSACTION;
24
25 UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
26 SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
27
28 # Block the applier on node #1 and issue a conflicting update on node #2
29 --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
30 SET SESSION wsrep_sync_wait=0;
31 --let $galera_sync_point = apply_monitor_slave_enter_sync
32 --source include/galera_set_sync_point.inc
33
34 --connection node_2
35 UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
36
37 --connection node_1a
38 --source include/galera_wait_sync_point.inc
39 --source include/galera_clear_sync_point.inc
40
41 # Block the commit, send the COMMIT and wait until it gets blocked
42
43 --let $galera_sync_point = commit_monitor_master_enter_sync
44 --source include/galera_set_sync_point.inc
45
46 --connection node_1
47 --send COMMIT
48
49 --connection node_1a
50
51 --let $galera_sync_point = apply_monitor_slave_enter_sync commit_monitor_master_enter_sync
52 --source include/galera_wait_sync_point.inc
53 --source include/galera_clear_sync_point.inc
54
55 # Let the conflicting UPDATE proceed and wait until it hits abort_trx_end.
56 # The victim transaction still sits in commit_monitor_master_sync_point.
57
58 --let $galera_sync_point = abort_trx_end
59 --source include/galera_set_sync_point.inc
60 --let $galera_sync_point = apply_monitor_slave_enter_sync
61 --source include/galera_signal_sync_point.inc
62 --let $galera_sync_point = abort_trx_end commit_monitor_master_enter_sync
63 --source include/galera_wait_sync_point.inc
64
65 # Let the transactions proceed
66 --source include/galera_clear_sync_point.inc
67 --let $galera_sync_point = abort_trx_end
68 --source include/galera_signal_sync_point.inc
69 --let $galera_sync_point = commit_monitor_master_enter_sync
70 --source include/galera_signal_sync_point.inc
71
72 # Commit succeeds
73 --connection node_1
74 --reap
75
76 # Confirm that NOW() is not stuck in time relative to SYSDATE();
77 --sleep 3
78 SELECT TIMEDIFF(SYSDATE(), NOW()) < 2;
79
80 INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND());
81 INSERT INTO rand_table VALUES (RAND()),(RAND()),(RAND()),(RAND()),(RAND());
82
83 SELECT COUNT(DISTINCT f1) = 10 FROM rand_table;
84
85 # wsrep_local_replays has increased by 1
86 --let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
87 --disable_query_log
88 --eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays;
89 --enable_query_log
90
91 --connection node_2
92 DROP TABLE t1;
93 DROP TABLE rand_table;