mirror of
https://github.com/MariaDB/server.git
synced 2025-02-23 05:43:08 +01:00

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>
123 lines
3.2 KiB
Text
123 lines
3.2 KiB
Text
#
|
|
# 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
|
|
--source include/have_debug_sync.inc
|
|
--source include/have_debug.inc
|
|
|
|
#
|
|
# Make bulk insert BF-abort, but regular insert succeed.
|
|
#
|
|
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
# Delay applying of the single insert from the other node.
|
|
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb';
|
|
|
|
--connection node_1
|
|
# 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 on this node.
|
|
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
|
|
|
|
# We need to trigger Galera-level certification conflict. For this:
|
|
# - start applying single insert from the other node before bulk insert certifies
|
|
# - certifying bulk insert will lead to the conflict
|
|
# - keep applying single insert
|
|
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached';
|
|
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb';
|
|
|
|
--error ER_LOCK_DEADLOCK
|
|
COMMIT;
|
|
|
|
DROP TABLE t1;
|
|
SET GLOBAL DEBUG_DBUG = '';
|
|
SET DEBUG_SYNC = 'RESET';
|
|
|
|
#
|
|
# Make bulk insert succeed, but regular insert BF-abort.
|
|
#
|
|
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
--connection node_2
|
|
# Delay applying of the bulk insert from the other node.
|
|
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_apply_cb';
|
|
|
|
--connection node_1
|
|
--let $before_bulk_keys = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_repl_keys'`
|
|
|
|
# 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 on this node.
|
|
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 three keys to be added for bulk insert: "zero-level" key, 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
|
|
|
|
# We need to trigger Galera-level certification conflict. For this:
|
|
# - start applying bulk insert from the other node before local insert certifies
|
|
# - certifying local insert will lead to the conflict
|
|
# - keep applying bulk insert
|
|
SET DEBUG_SYNC = 'wsrep_before_certification WAIT_FOR sync.wsrep_apply_cb_reached';
|
|
SET DEBUG_SYNC = 'wsrep_after_certification SIGNAL signal.wsrep_apply_cb';
|
|
|
|
--error ER_LOCK_DEADLOCK
|
|
COMMIT;
|
|
|
|
DROP TABLE t1;
|
|
SET GLOBAL DEBUG_DBUG = '';
|
|
SET DEBUG_SYNC = 'RESET';
|
|
--source include/galera_end.inc
|