mariadb/mysql-test/suite/rpl/r/rpl_parallel_seq.result
Andrei 8c817e2d8a MDEV-35570 parallel slave ALTER-SEQUENCE attempted to binlog out-of-order
Since MDEV-31503 fixes ALTER-SEQUENCE might be able to  complete its
work including binlogging before a preceding in binlog-order
transaction. There may not be data dependency between the two
transactions, but there would be
   "an attempt was made to binlog GTID D-S-XYZ which would create an
   out-of-order sequence number"
error in the gtid_strict_mode = ON.

After the preceding transaction started committing, and does it rather
slow, ALTER-SEQUNCE was able to find a time window to complete because
it temporarily releases its link with the waitee parent transaction.
And while having it released it also erroneously executes the binlogging part.

Fixed with restoring the commit dependency on the parent before
ALTER-SEQUNCE takes on binlogging.
2025-07-07 13:00:18 +03:00

164 lines
4.9 KiB
Text

include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
# MDEV-29621 the sequence engine binlog_row_image-full events
# MDL-deadlock on the parallel slave.
connection master;
CREATE SEQUENCE s1;
SET @@session.binlog_row_image=FULL;
SET @@session.debug_dbug="+d,binlog_force_commit_id";
SET @commit_id=7;
SET @@gtid_seq_no=100;
SELECT NEXT VALUE FOR s1;
NEXT VALUE FOR s1
1
INSERT INTO s1 VALUES(2, 1, 10, 1, 2, 1, 1, 0);
SET @@session.debug_dbug="";
connection slave;
SET @@global.slave_parallel_threads=2;
SET @@global.slave_parallel_mode=optimistic;
SET @@global.debug_dbug="+d,hold_worker_on_schedule";
include/start_slave.inc
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
connection master;
DROP SEQUENCE s1;
connection slave;
include/stop_slave.inc
# Simulate buggy 10.3.36 master to prove the parallel applier
# does not deadlock now at replaying the above master load.
connection master;
include/rpl_stop_server.inc [server_number=1]
include/rpl_start_server.inc [server_number=1]
connection slave;
RESET MASTER;
SET @@global.gtid_slave_pos="";
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1, master_user='root', master_use_gtid=slave_pos;
START SLAVE UNTIL MASTER_GTID_POS='0-1-102';
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
# Normal stop is expected
include/wait_for_slave_to_stop.inc
# MDEV-31077 ALTER SEQUENCE may end up in optimistic parallel slave binlog out-of-order
# The test proves ALTER-SEQUENCE binlogs first before the following transaction does so.
connection slave;
include/stop_slave.inc
Warnings:
Note 1255 Slave already has been stopped
RESET MASTER;
SET @@global.gtid_slave_pos="";
connection master;
RESET MASTER;
CREATE TABLE ti (a INT) ENGINE=innodb;
CREATE SEQUENCE s2 ENGINE=innodb;
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
include/stop_slave.inc
include/rpl_restart_server.inc [server_number=2]
SET @@global.slave_parallel_threads=2;
SET @@global.slave_parallel_mode=optimistic;
SET @@global.debug_dbug="+d,hold_worker_on_schedule";
SET @@global.gtid_strict_mode=1;
connection master;
SET @@gtid_seq_no=100;
ALTER SEQUENCE s2 restart with 1;
INSERT INTO ti SET a=1;
include/save_master_gtid.inc
SELECT @@global.gtid_binlog_state "Master gtid state";
Master gtid state
0-1-101
connection slave;
SET STATEMENT sql_log_bin=0 FOR FLUSH TABLES;
include/start_slave.inc
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "no 100,101 yet in both";
@@global.gtid_binlog_state no 100,101 yet in both
0-1-2 0-1-2
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
# Normal sync with master proves the fixes correct
include/sync_with_master_gtid.inc
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "all through 101 have been committed";
@@global.gtid_binlog_state all through 101 have been committed
0-1-101 0-1-101
connection slave;
include/stop_slave.inc
set @saved_mode= @@global.slave_parallel_mode;
set @@global.slave_parallel_mode = conservative;
include/start_slave.inc
connection master;
INSERT INTO ti SET a=2;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
lock table ti write;
SET GLOBAL debug_dbug= "+d,halt_past_mark_start_commit";
connection master;
INSERT INTO ti SET a=35570;
ALTER SEQUENCE s2 restart with 1;
include/save_master_gtid.inc
connection slave;
unlock tables;
SET debug_sync = "now SIGNAL past_mark_continue";
include/sync_with_master_gtid.inc
include/stop_slave.inc
SET @@global.slave_parallel_mode = @saved_mode;
SET @@global.debug_dbug = @@GLOBAL.debug_dbug;
include/start_slave.inc
connection slave;
flush tables with read lock;
connection master;
CREATE OR REPLACE SEQUENCE s3 ENGINE=innodb;
SELECT NEXT VALUE FOR s3 into @tmpvar;
include/save_master_gtid.inc
connection slave;
unlock tables;
include/sync_with_master_gtid.inc
connection slave;
flush tables with read lock;
connection master;
CREATE OR REPLACE SEQUENCE s3 ENGINE=innodb;
SELECT NEXT VALUE FOR s3 into @tmpvar;
include/save_master_gtid.inc
connection slave;
unlock tables;
include/sync_with_master_gtid.inc
connection slave;
BEGIN /* slave local Trx */;
select count(*) from s3;
count(*)
1
connection master;
CREATE OR REPLACE SEQUENCE s3 ENGINE=innodb;
SELECT NEXT VALUE FOR s3 into @tmpvar;
include/save_master_gtid.inc
connection slave;
connection slave;
rollback /* Trx */;
include/sync_with_master_gtid.inc
connection slave;
include/stop_slave.inc
SET debug_sync = RESET;
SET @@global.slave_parallel_threads= 0;
SET @@global.slave_parallel_mode= optimistic;
SET @@global.debug_dbug = "";
SET @@global.gtid_strict_mode=0;
include/start_slave.inc
connection master;
BEGIN;
INSERT INTO ti SET a=32593;
CREATE SEQUENCE s4;
DROP SEQUENCE s2,s3,s4;
DROP TABLE ti;
connection slave;
connection master;
CREATE SEQUENCE s;
SELECT NEXTVAL(s);
NEXTVAL(s)
1
flush binary logs;
DROP SEQUENCE s;
DROP SEQUENCE s;
connection slave;
connection master;
include/rpl_end.inc