Debian Codegraph @

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

raw
1 --source include/galera_cluster.inc
2 --source include/have_debug.inc
3 --source include/have_debug_sync.inc
4 --source include/galera_have_debug_sync.inc
5
6 --connection node_1
7 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(255)) Engine=InnoDB;
8
9 DELIMITER |;
10 CREATE PROCEDURE insert_proc ()
11 BEGIN
12 DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
13 BEGIN
14 GET DIAGNOSTICS CONDITION 1 @errno = MYSQL_ERRNO;
15 END;
16 INSERT INTO t1 VALUES (1, 'node 1'),(2, 'node 1');
17 INSERT INTO t1 VALUES (3, 'node 1');
18 END|
19 DELIMITER ;|
20
21 # We need two slave threads here to guarantee progress.
22 # If we use only one thread the following could happen
23 # in node_1:
24 # We block the only slave thread in wsrep_apply_cb and we
25 # issue an INSERT (by calling the stored procedure) that will
26 # try to acquire galera's local monitor in pre_commit().
27 # This usually works fine, except for when a commit cut event
28 # sneaks in the slave queue and gets a local seqno smaller than
29 # that of the INSERT. Because there is only one slave thread,
30 # commit cut is not processed and therefore does not advance
31 # local monitor, and our INSERT remains stuck there.
32
33 SET GLOBAL wsrep_slave_threads = 2;
34 SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb";
35
36 --let $expected_cert_failures = `SELECT VARIABLE_VALUE + 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_cert_failures'`
37
38 --connection node_2
39 --send INSERT INTO t1 VALUES (1, 'node 2');
40
41 --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
42 --connection node_1a
43 SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached";
44
45 --connection node_1
46 SET SESSION wsrep_sync_wait = 0;
47 --send CALL insert_proc ();
48
49 --connection node_1a
50 SET SESSION wsrep_sync_wait = 0;
51 --let $wait_condition = SELECT VARIABLE_VALUE = $expected_cert_failures FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_cert_failures'
52 --source include/wait_condition.inc
53
54
55 SET GLOBAL DEBUG_DBUG = "";
56 SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb";
57
58 --connection node_2
59 --reap
60
61 --connection node_1
62 # We expect no errors here, because the handler in insert_proc() caught the deadlock error
63 --reap
64 SELECT @errno = 1213;
65 SELECT * FROM t1;
66
67 --connection node_2
68 SELECT * FROM t1;
69
70 --connection node_1
71 SET GLOBAL wsrep_slave_threads = DEFAULT;
72 DROP TABLE t1;
73 DROP PROCEDURE insert_proc;
74
75 SET GLOBAL debug_dbug = NULL;
76 SET debug_sync='RESET';
77
78 # Make sure no pending signals are leftover to surprise subsequent tests.
79 SELECT @@debug_sync;