summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_insert_bulk.test
blob: f58870d5f74b7665bd2eacb88817ca2cfa61a90c (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
83
84
85
86
87
88
#
# Test that bulk insert replicates as table-level exclusive key and
# rolls back properly if needed.
#

--source include/galera_cluster.inc
--source include/have_innodb.inc

#
# Make bulk insert BF-abort, but regular insert succeed.
#

--connection node_1
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;

# Disable foreign and unique key checks to allow bulk insert.
SET foreign_key_checks = 0;
SET unique_checks = 0;

START TRANSACTION;

--let $count=0
--disable_query_log
while ($count < 1000)
{
  --eval INSERT INTO t1 VALUES ($count)
  --inc $count
}
--enable_query_log

--connection node_2

# Disable bulk insert.
SET foreign_key_checks = 1;
SET unique_checks = 1;

# Insert a value out of the bulk insert range.
INSERT INTO t1 VALUES (1001);

--connection node_1
--error ER_LOCK_DEADLOCK
COMMIT;

DROP TABLE t1;

#
# Make bulk insert succeed, but regular insert BF-abort.
#

--connection node_1
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;

--let $before_bulk_keys = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_repl_keys'`

START TRANSACTION;

--let $count=0
--disable_query_log
while ($count < 1000)
{
  --eval INSERT INTO t1 VALUES ($count)
  --inc $count
}
--enable_query_log

--connection node_2

# Disable bulk insert.
SET foreign_key_checks = 1;
SET unique_checks = 1;

START TRANSACTION;

# Insert a value out of the bulk insert range.
INSERT INTO t1 VALUES (1001);

--connection node_1
COMMIT;

# Expect two keys to be added for bulk insert: DB-level shared key and table-level exclusive key.
--let $bulk_keys_count = `SELECT VARIABLE_VALUE - $before_bulk_keys FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_repl_keys'`
--echo $bulk_keys_count

--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;

DROP TABLE t1;