summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/MW-328A.test
blob: 2435a9e2c2e1ee5e013bd81b0847d011a4c12724 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#
# MW-328 Fix unnecessary/silent BF aborts
# 

#
# test phase 1 is not deterministic
#
# Here we attempt to insert into t2 and check if insert actually
# inserted rows if a success was reported.
#
# However, deadlocks may or may not happen in this test execution
# it all depends on timing.
#

--source include/galera_cluster.inc
--source include/force_restart.inc
--source suite/galera/t/MW-328-header.inc

--connection node_1
call mtr.add_suppression("WSREP: Wait for gtid returned error 3 while waiting for prior transactions to commit before setting position");

--connection node_2
call mtr.add_suppression("WSREP: Wait for gtid returned error 3 while waiting for prior transactions to commit before setting position");
--let $count = 100
--let $successes = 0
--let $deadlocks = 0

SET SESSION wsrep_retry_autocommit = 0;

--disable_query_log

while ($count)
{
  TRUNCATE TABLE t2;

  --error 0,ER_LOCK_DEADLOCK
  INSERT IGNORE INTO t2 SELECT f2 FROM t1;
  if ($mysql_errno != 1213) {
    --inc $successes
    if (`SELECT COUNT(*) = 0 FROM t2`) {
      --die No rows arrived in table t2
    }
  }

  if ($mysql_errno == 1213) {
    --inc $deadlocks
      
  }

  --dec $count
}

--enable_query_log


--source suite/galera/t/MW-328-footer.inc

#
# Test phase 2 is deterministic
# Here we generate a sure conflict in node 1 and verify that
# insert failed in both nodes
#
--connection node_1
CREATE TABLE t1 (i int primary key, j int) engine=innodb;
INSERT INTO t1 values (1,0);

BEGIN;
UPDATE t1 SET j=1 WHERE i=1;

--connection node_2
UPDATE t1 SET j=2 WHERE i=1;

--connection node_1
--error ER_LOCK_DEADLOCK
COMMIT;

SELECT * FROM t1;
--connection node_2
SELECT * FROM t1;
--connection node_1

DROP TABLE t1;