mariadb/mysql-test/suite/galera_3nodes/r/MDEV-36360.result
Denis Protivensky c01bff4a10 MDEV-36360: Don't grab table-level X locks for applied inserts
It prevents a crash in wsrep_report_error() which happened when appliers would run
with FK and UK checks disabled and erroneously execute plain inserts as bulk inserts.

Moreover, in release builds such a behavior could lead to deadlocks between two applier
threads if a thread waiting for a table-level lock was ordered before the lock holder.
In that case the lock holder would proceed to commit order and wait forever for the
now-blocked other applier thread to commit before.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2025-04-02 04:50:30 +02:00

61 lines
1.4 KiB
Text

connection node_2;
connection node_1;
connection node_1;
connection node_2;
connection node_3;
connection node_1;
CREATE TABLE parent (
id INT PRIMARY KEY
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id INT,
KEY (parent_id),
CONSTRAINT FOREIGN KEY (parent_id) REFERENCES parent(id)
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1), (2);
connection node_3;
SET SESSION wsrep_on = OFF;
DELETE FROM parent WHERE id = 1;
SET SESSION wsrep_on = ON;
Restarting server 3 with one applier thread having FK and UK checks disabled
SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_after_write_row';
connection node_1;
INSERT INTO child VALUES (1, 1);
connection node_3;
SET DEBUG_SYNC = 'now WAIT_FOR sync.wsrep_after_write_row_reached';
SET GLOBAL DEBUG_DBUG = '';
SET wsrep_sync_wait = 0;
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL signal.wsrep_after_write_row';
INSERT INTO child VALUES (2, 2);
SET DEBUG_SYNC = 'RESET';
include/assert_grep.inc [no FK constraint failure]
Server 3
SELECT COUNT(*) AS EXPECT_1 FROM parent;
EXPECT_1
1
SELECT COUNT(*) AS EXPECT_2 FROM child;
EXPECT_2
2
connection node_1;
Server 1
SET wsrep_sync_wait = 15;
SELECT COUNT(*) AS EXPECT_2 FROM parent;
EXPECT_2
2
SELECT COUNT(*) AS EXPECT_2 FROM child;
EXPECT_2
2
connection node_2;
Server 2
SET wsrep_sync_wait = 15;
SELECT COUNT(*) AS EXPECT_2 FROM parent;
EXPECT_2
2
SELECT COUNT(*) AS EXPECT_2 FROM child;
EXPECT_2
2
DROP TABLE child;
DROP TABLE parent;
disconnect node_2;
disconnect node_1;