Skip to content

Commit 1c48950

Browse files
denis-protivenskysysprg
authored andcommitted
MDEV-30536: Fix Galera bulk insert optimization MTR test
After closing https://github.com/codership/galera-bugs/issues/947, Galera now correctly certifies table-level keys, which made bulk insert work again. The corresponding MTR test is made deterministic and re-enabled. Requires Galera 26.4.19 Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
1 parent bac0804 commit 1c48950

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

mysql-test/suite/galera/disabled.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ galera_as_slave_ctas : MDEV-28378 timeout
1414
galera_pc_recovery : MDEV-25199 cluster fails to start up
1515
galera_bf_kill_debug : timeout after 900 seconds
1616
galera_ssl_upgrade : [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 130: Incorrect file format 'gtid_slave_pos'
17-
galera_insert_bulk : MDEV-30536 no expected deadlock in galera_insert_bulk test
1817
galera_sequences : MDEV-32561 WSREP FSM failure: no such a transition REPLICATING -> COMMITTED
1918
galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the galera::ReplicatorSMM::finish_cert()
2019
galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback()

mysql-test/suite/galera/r/galera_insert_bulk.result

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ connection node_2;
22
connection node_1;
33
connection node_1;
44
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
5+
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb';
6+
connection node_1;
57
SET foreign_key_checks = 0;
68
SET unique_checks = 0;
79
START TRANSACTION;
@@ -10,11 +12,20 @@ SET foreign_key_checks = 1;
1012
SET unique_checks = 1;
1113
INSERT INTO t1 VALUES (1001);
1214
connection node_1;
15+
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached';
16+
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb';
1317
COMMIT;
1418
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
1519
DROP TABLE t1;
20+
SET GLOBAL DEBUG_DBUG = '';
21+
SET DEBUG_SYNC = 'RESET';
1622
connection node_1;
1723
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
24+
connection node_2;
25+
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb';
26+
connection node_1;
27+
SET foreign_key_checks = 0;
28+
SET unique_checks = 0;
1829
START TRANSACTION;
1930
connection node_2;
2031
SET foreign_key_checks = 1;
@@ -23,8 +34,14 @@ START TRANSACTION;
2334
INSERT INTO t1 VALUES (1001);
2435
connection node_1;
2536
COMMIT;
26-
2
37+
3
2738
connection node_2;
39+
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached';
40+
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb';
2841
COMMIT;
2942
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
3043
DROP TABLE t1;
44+
SET GLOBAL DEBUG_DBUG = '';
45+
SET DEBUG_SYNC = 'RESET';
46+
disconnect node_2;
47+
disconnect node_1;

mysql-test/suite/galera/t/galera_insert_bulk.test

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
--source include/galera_cluster.inc
77
--source include/have_innodb.inc
8+
--source include/have_debug_sync.inc
9+
--source include/have_debug.inc
810

911
#
1012
# Make bulk insert BF-abort, but regular insert succeed.
@@ -13,6 +15,10 @@
1315
--connection node_1
1416
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
1517

18+
# Delay applying of the single insert from the other node.
19+
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb';
20+
21+
--connection node_1
1622
# Disable foreign and unique key checks to allow bulk insert.
1723
SET foreign_key_checks = 0;
1824
SET unique_checks = 0;
@@ -30,18 +36,28 @@ while ($count < 1000)
3036

3137
--connection node_2
3238

33-
# Disable bulk insert.
39+
# Disable bulk insert on this node.
3440
SET foreign_key_checks = 1;
3541
SET unique_checks = 1;
3642

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

4046
--connection node_1
47+
48+
# We need to trigger Galera-level certification conflict. For this:
49+
# - start applying single insert from the other node before bulk insert certifies
50+
# - certifying bulk insert will lead to the conflict
51+
# - keep applying single insert
52+
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached';
53+
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb';
54+
4155
--error ER_LOCK_DEADLOCK
4256
COMMIT;
4357

4458
DROP TABLE t1;
59+
SET GLOBAL DEBUG_DBUG = '';
60+
SET DEBUG_SYNC = 'RESET';
4561

4662
#
4763
# Make bulk insert succeed, but regular insert BF-abort.
@@ -50,8 +66,17 @@ DROP TABLE t1;
5066
--connection node_1
5167
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
5268

69+
--connection node_2
70+
# Delay applying of the bulk insert from the other node.
71+
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb';
72+
73+
--connection node_1
5374
--let $before_bulk_keys = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_repl_keys'`
5475

76+
# Disable foreign and unique key checks to allow bulk insert.
77+
SET foreign_key_checks = 0;
78+
SET unique_checks = 0;
79+
5580
START TRANSACTION;
5681

5782
--let $count=0
@@ -64,8 +89,7 @@ while ($count < 1000)
6489
--enable_query_log
6590

6691
--connection node_2
67-
68-
# Disable bulk insert.
92+
# Disable bulk insert on this node.
6993
SET foreign_key_checks = 1;
7094
SET unique_checks = 1;
7195

@@ -77,12 +101,23 @@ INSERT INTO t1 VALUES (1001);
77101
--connection node_1
78102
COMMIT;
79103

80-
# Expect two keys to be added for bulk insert: DB-level shared key and table-level exclusive key.
104+
# Expect three keys to be added for bulk insert: "zero-level" key, DB-level shared key and table-level exclusive key.
81105
--let $bulk_keys_count = `SELECT VARIABLE_VALUE - $before_bulk_keys FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_repl_keys'`
82106
--echo $bulk_keys_count
83107

84108
--connection node_2
109+
110+
# We need to trigger Galera-level certification conflict. For this:
111+
# - start applying bulk insert from the other node before local insert certifies
112+
# - certifying local insert will lead to the conflict
113+
# - keep applying bulk insert
114+
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached';
115+
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb';
116+
85117
--error ER_LOCK_DEADLOCK
86118
COMMIT;
87119

88120
DROP TABLE t1;
121+
SET GLOBAL DEBUG_DBUG = '';
122+
SET DEBUG_SYNC = 'RESET';
123+
--source include/galera_end.inc

0 commit comments

Comments
 (0)