--source include/have_innodb.inc --source include/have_debug.inc --source include/have_debug_sync.inc --source include/have_binlog_format_mixed.inc --source include/master-slave.inc --connection slave --source include/stop_slave.inc SET @old_parallel_threads= @@GLOBAL.slave_parallel_threads; SET GLOBAL slave_parallel_threads=3; SET @old_parallel_mode= @@GLOBAL.slave_parallel_mode; SET GLOBAL slave_parallel_mode=aggressive; SET @old_dbug= @@GLOBAL.debug_dbug; CHANGE MASTER TO master_use_gtid=slave_pos; --source include/start_slave.inc --echo *** MDEV-31509: Lost data with FTWRL and STOP SLAVE # The bug was as follows: # 1. Event groups T1 and T2 are queued but not started yet. # 2. FLUSH TABLE WITH READ LOCKS starts, sets rpl_parallel_entry::pause_sub_id # 3. T2 Sees pause_sub_id, goes to wait for the pause to complete. # 4. FTWRL completes, UNLOCK TABLES is run. # 5. STOP SLAVE is run, sets rpl_parallel_entry::stop_sub_id. # 6. T2 wakes up after FTWRL pause, only now sets # rpl_parallel_entry::largest_started_sub_id. This is the bug, # largest_started_sub_id is set too late here. # 7. T1 starts, it sees stop_sub_id