Commit 8bedb638 authored by Kristian Nielsen's avatar Kristian Nielsen

MDEV-8113: Parallel slave: slave hangs on ALTER TABLE (or other DDL) as the...

MDEV-8113: Parallel slave: slave hangs on ALTER TABLE (or other DDL) as the first event after slave start

In optimistic parallel replication, it is not safe to try to run a following
transaction in parallel with a DDL statement, and there is code to prevent
this.

However, the code was missing the case where the DDL is the very first event
after slave start. In this case, following transactions could run in
parallel with the DDL, which can cause the slave to hang or even corrupt
slave in unlucky cases.
parent ecfc3de5
...@@ -455,6 +455,47 @@ a b ...@@ -455,6 +455,47 @@ a b
include/stop_slave.inc include/stop_slave.inc
SET GLOBAL debug_dbug= @old_debug; SET GLOBAL debug_dbug= @old_debug;
include/start_slave.inc include/start_slave.inc
*** MDEV-8113: ALTER TABLE causes slave hang in optimistic parallel replication ***
include/stop_slave.inc
ALTER TABLE t2 ADD c INT;
INSERT INTO t2 (a,b) VALUES (50, 0);
INSERT INTO t2 (a,b) VALUES (51, 1);
INSERT INTO t2 (a,b) VALUES (52, 2);
INSERT INTO t2 (a,b) VALUES (53, 3);
INSERT INTO t2 (a,b) VALUES (54, 4);
INSERT INTO t2 (a,b) VALUES (55, 5);
INSERT INTO t2 (a,b) VALUES (56, 6);
INSERT INTO t2 (a,b) VALUES (57, 7);
INSERT INTO t2 (a,b) VALUES (58, 8);
INSERT INTO t2 (a,b) VALUES (59, 9);
ALTER TABLE t2 DROP COLUMN c;
SELECT * FROM t2 WHERE a >= 50 ORDER BY a;
a b
50 0
51 1
52 2
53 3
54 4
55 5
56 6
57 7
58 8
59 9
include/save_master_gtid.inc
include/start_slave.inc
include/sync_with_master_gtid.inc
SELECT * FROM t2 WHERE a >= 50 ORDER BY a;
a b
50 0
51 1
52 2
53 3
54 4
55 5
56 6
57 7
58 8
59 9
include/stop_slave.inc include/stop_slave.inc
SET GLOBAL slave_parallel_mode=@old_parallel_mode; SET GLOBAL slave_parallel_mode=@old_parallel_mode;
SET GLOBAL slave_parallel_threads=@old_parallel_threads; SET GLOBAL slave_parallel_threads=@old_parallel_threads;
......
...@@ -429,6 +429,33 @@ SET GLOBAL debug_dbug= @old_debug; ...@@ -429,6 +429,33 @@ SET GLOBAL debug_dbug= @old_debug;
--source include/start_slave.inc --source include/start_slave.inc
--echo *** MDEV-8113: ALTER TABLE causes slave hang in optimistic parallel replication ***
--connection server_2
--source include/stop_slave.inc
--connection server_1
ALTER TABLE t2 ADD c INT;
INSERT INTO t2 (a,b) VALUES (50, 0);
INSERT INTO t2 (a,b) VALUES (51, 1);
INSERT INTO t2 (a,b) VALUES (52, 2);
INSERT INTO t2 (a,b) VALUES (53, 3);
INSERT INTO t2 (a,b) VALUES (54, 4);
INSERT INTO t2 (a,b) VALUES (55, 5);
INSERT INTO t2 (a,b) VALUES (56, 6);
INSERT INTO t2 (a,b) VALUES (57, 7);
INSERT INTO t2 (a,b) VALUES (58, 8);
INSERT INTO t2 (a,b) VALUES (59, 9);
ALTER TABLE t2 DROP COLUMN c;
SELECT * FROM t2 WHERE a >= 50 ORDER BY a;
--source include/save_master_gtid.inc
--connection server_2
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
SELECT * FROM t2 WHERE a >= 50 ORDER BY a;
# Clean up. # Clean up.
--connection server_2 --connection server_2
......
...@@ -2299,6 +2299,11 @@ rpl_parallel::do_event(rpl_group_info *serial_rgi, Log_event *ev, ...@@ -2299,6 +2299,11 @@ rpl_parallel::do_event(rpl_group_info *serial_rgi, Log_event *ev,
} }
gco->flags= flags; gco->flags= flags;
} }
else
{
if (gtid_flags & Gtid_log_event::FL_DDL)
force_switch_flag= group_commit_orderer::FORCE_SWITCH;
}
rgi->speculation= speculation; rgi->speculation= speculation;
if (gtid_flags & Gtid_log_event::FL_GROUP_COMMIT_ID) if (gtid_flags & Gtid_log_event::FL_GROUP_COMMIT_ID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment