summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test
blob: b82a160657dcc8af475ece1f6568772f974743bb (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
89
90
91
92
93
##
## Tests the parallel application of many small-ish auto-increment insert transactions
##

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

--connection node_1
CREATE TABLE ten (f1 INTEGER) Engine=InnoDB;
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);

CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB;

# Create few connections to node1 so that we can run transactions concurrently
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc

--let $galera_connection_name = node_1b
--let $galera_server_number = 1
--source include/galera_connect.inc

--connection node_2
set session wsrep_sync_wait=15;
--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads`

SET GLOBAL wsrep_slave_threads = 4;
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count';
--source include/wait_condition.inc

--connection node_1
DELIMITER |;
CREATE PROCEDURE p1 (repeat_count int)
BEGIN
  DECLARE current_num int;
  SET current_num = 0;
  WHILE current_num < repeat_count do
    INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1;
    COMMIT;
    SET current_num = current_num + 1;
  END WHILE;
END|
DELIMITER ;|

--disable_query_log
send call p1(1000);

--connection node_1a
--disable_query_log
send call p1(1000);

--connection node_1b
--disable_query_log
send call p1(1000);

--connection node_2
--disable_query_log
send call p1(1000);

--connection node_1
reap;
--enable_query_log

--connection node_1a
reap;
--enable_query_log

--connection node_1b
reap;
--enable_query_log

--connection node_2
reap;
--enable_query_log

SELECT COUNT(*) FROM t1;
SELECT COUNT(DISTINCT f1) FROM t1;

--disconnect node_1a
--disconnect node_1b

--disable_query_log
--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig;
--enable_query_log

--connection default
DROP TABLE t1;
DROP TABLE ten;
DROP PROCEDURE p1;