mirror of
https://github.com/MariaDB/server.git
synced 2025-08-05 13:16:09 +03:00
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.
266 lines
8.1 KiB
Plaintext
266 lines
8.1 KiB
Plaintext
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
--source include/have_debug_sync.inc
|
|
--source include/have_binlog_format_row.inc
|
|
--source include/master-slave.inc
|
|
|
|
--connection slave
|
|
--source include/stop_slave.inc
|
|
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
|
|
|
--echo # MDEV-29621 the sequence engine binlog_row_image-full events
|
|
--echo # 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;
|
|
--disable_ps2_protocol
|
|
SELECT NEXT VALUE FOR s1;
|
|
--enable_ps2_protocol
|
|
INSERT INTO s1 VALUES(2, 1, 10, 1, 2, 1, 1, 0);
|
|
SET @@session.debug_dbug="";
|
|
|
|
--connection slave
|
|
--let $slave_parallel_threads=`select @@global.slave_parallel_threads`
|
|
--let $slave_parallel_mode=`select @@global.slave_parallel_mode`
|
|
SET @@global.slave_parallel_threads=2;
|
|
SET @@global.slave_parallel_mode=optimistic;
|
|
SET @@global.debug_dbug="+d,hold_worker_on_schedule";
|
|
--source include/start_slave.inc
|
|
|
|
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to start commit"
|
|
--source include/wait_condition.inc
|
|
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
|
|
|
--connection master
|
|
DROP SEQUENCE s1;
|
|
--sync_slave_with_master
|
|
--source include/stop_slave.inc
|
|
|
|
--echo # Simulate buggy 10.3.36 master to prove the parallel applier
|
|
--echo # does not deadlock now at replaying the above master load.
|
|
--connection master
|
|
--let $datadir= `SELECT @@datadir`
|
|
|
|
--let $rpl_server_number= 1
|
|
--source include/rpl_stop_server.inc
|
|
|
|
--remove_file $datadir/master-bin.000001
|
|
--copy_file $MYSQL_TEST_DIR/std_data/rpl/master-bin-seq_10.3.36.000001 $datadir/master-bin.000001
|
|
|
|
--let $rpl_server_number= 1
|
|
--source include/rpl_start_server.inc
|
|
|
|
--source include/wait_until_connected_again.inc
|
|
--save_master_pos
|
|
|
|
--connection slave
|
|
RESET MASTER;
|
|
SET @@global.gtid_slave_pos="";
|
|
|
|
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
|
|
eval 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';
|
|
|
|
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit"
|
|
--source include/wait_condition.inc
|
|
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
|
|
|
--echo # Normal stop is expected
|
|
--source include/wait_for_slave_to_stop.inc
|
|
|
|
--echo # MDEV-31077 ALTER SEQUENCE may end up in optimistic parallel slave binlog out-of-order
|
|
--echo # The test proves ALTER-SEQUENCE binlogs first before the following transaction does so.
|
|
|
|
--connection slave
|
|
--source include/stop_slave.inc
|
|
RESET MASTER;
|
|
SET @@global.gtid_slave_pos="";
|
|
--connection master
|
|
RESET MASTER;
|
|
|
|
# Load from master
|
|
CREATE TABLE ti (a INT) ENGINE=innodb;
|
|
CREATE SEQUENCE s2 ENGINE=innodb;
|
|
--source include/save_master_gtid.inc
|
|
|
|
--connection slave
|
|
--source include/start_slave.inc
|
|
--source include/sync_with_master_gtid.inc
|
|
--source include/stop_slave.inc
|
|
--let $rpl_server_number= 2
|
|
--source include/rpl_restart_server.inc
|
|
# upon restart
|
|
SET @@global.slave_parallel_threads=2;
|
|
SET @@global.slave_parallel_mode=optimistic;
|
|
SET @@global.debug_dbug="+d,hold_worker_on_schedule";
|
|
--let $slave_gtid_strict_mode=`select @@global.gtid_strict_mode`
|
|
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;
|
|
--source include/save_master_gtid.inc
|
|
SELECT @@global.gtid_binlog_state "Master gtid state";
|
|
|
|
--connection slave
|
|
# The following FT complicates the opening table time with committing
|
|
# an internal transaction. The rest of the test also proves
|
|
# MDEV-31503 "branch" of the OOO error is fixed.
|
|
SET STATEMENT sql_log_bin=0 FOR FLUSH TABLES;
|
|
--source include/start_slave.inc
|
|
|
|
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit"
|
|
--source include/wait_condition.inc
|
|
|
|
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "no 100,101 yet in both";
|
|
|
|
# DEBUG_DBUG extension point of hold_worker_on_schedule is reused
|
|
# (gets deployed) in Sql_cmd_alter_sequence::execute.
|
|
SET DEBUG_SYNC = 'now SIGNAL continue_worker';
|
|
|
|
--echo # Normal sync with master proves the fixes correct
|
|
--source include/sync_with_master_gtid.inc
|
|
|
|
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "all through 101 have been committed";
|
|
|
|
#
|
|
# MDEV-35570 parallel slave ALTER-SEQUNCE attemted to binlog out-of-order.
|
|
# Let two transactions I_1 -> AS_2 where AS_2 depends on a commit parent I_1.
|
|
# Under the bug condition AS_2 may complete its work including binlogging
|
|
# while I_1 is slowly executing Xid_log_event.
|
|
# The test simulate the slowness, AS_2 must defer its completion.
|
|
#
|
|
--connection slave
|
|
--source include/stop_slave.inc
|
|
set @saved_mode= @@global.slave_parallel_mode;
|
|
set @@global.slave_parallel_mode = conservative;
|
|
--source include/start_slave.inc
|
|
|
|
--connection master
|
|
INSERT INTO ti SET a=2;
|
|
--source include/save_master_gtid.inc
|
|
|
|
--connection slave
|
|
--source include/sync_with_master_gtid.inc
|
|
# allow to proceed to sync with the 1st following WFPT2SC wait condtion
|
|
lock table ti write;
|
|
# allow to proceed into commit to sync with the 2nd following WFPC wait condition
|
|
--let $saved_dbug= @@GLOBAL.debug_dbug
|
|
SET GLOBAL debug_dbug= "+d,halt_past_mark_start_commit";
|
|
|
|
--connection master
|
|
INSERT INTO ti SET a=35570;
|
|
ALTER SEQUENCE s2 restart with 1;
|
|
--source include/save_master_gtid.inc
|
|
|
|
--connection slave
|
|
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to start commit"
|
|
--source include/wait_condition.inc
|
|
# the 1st wait release
|
|
unlock tables;
|
|
|
|
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit"
|
|
--source include/wait_condition.inc
|
|
# the 2nd wait release
|
|
SET debug_sync = "now SIGNAL past_mark_continue";
|
|
|
|
--source include/sync_with_master_gtid.inc
|
|
--source include/stop_slave.inc
|
|
SET @@global.slave_parallel_mode = @saved_mode;
|
|
--eval SET @@global.debug_dbug = $saved_dbug
|
|
--source include/start_slave.inc
|
|
|
|
# MDEV-31792 Assertion in MDL_context::acquire_lock upon parallel replication of CREATE SEQUENCE
|
|
|
|
--let $iter = 3
|
|
while ($iter)
|
|
{
|
|
--connection slave
|
|
if (`select $iter > 1`)
|
|
{
|
|
flush tables with read lock;
|
|
}
|
|
if (`select $iter = 1`)
|
|
{
|
|
BEGIN /* slave local Trx */;
|
|
select count(*) from s3;
|
|
}
|
|
|
|
--connection master
|
|
CREATE OR REPLACE SEQUENCE s3 ENGINE=innodb;
|
|
# select may return non-deterministically, don't print its result
|
|
--disable_cursor_protocol
|
|
SELECT NEXT VALUE FOR s3 into @tmpvar;
|
|
--enable_cursor_protocol
|
|
--source include/save_master_gtid.inc
|
|
|
|
--connection slave
|
|
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to start commit%"
|
|
--source include/wait_condition.inc
|
|
|
|
if (`select $iter > 1`)
|
|
{
|
|
unlock tables;
|
|
}
|
|
if (`select $iter = 1`)
|
|
{
|
|
--connection slave
|
|
rollback /* Trx */;
|
|
}
|
|
|
|
|
|
--source include/sync_with_master_gtid.inc
|
|
|
|
--dec $iter
|
|
}
|
|
|
|
|
|
#
|
|
# MDEV-29621/MDEV-31077/MDEV-31792 clean up.
|
|
#
|
|
--connection slave
|
|
--source include/stop_slave.inc
|
|
|
|
SET debug_sync = RESET;
|
|
--eval SET @@global.slave_parallel_threads= $slave_parallel_threads
|
|
--eval SET @@global.slave_parallel_mode= $slave_parallel_mode
|
|
SET @@global.debug_dbug = "";
|
|
--eval SET @@global.gtid_strict_mode=$slave_gtid_strict_mode
|
|
--source include/start_slave.inc
|
|
|
|
--connection master
|
|
# MDEV-32593 Assertion failure upon CREATE SEQUENCE
|
|
BEGIN;
|
|
INSERT INTO ti SET a=32593;
|
|
CREATE SEQUENCE s4;
|
|
|
|
DROP SEQUENCE s2,s3,s4;
|
|
DROP TABLE ti;
|
|
|
|
--sync_slave_with_master
|
|
|
|
# MDEV-31779 server crash in Rows_log_event::update_sequence at replaying binlog
|
|
--connection master
|
|
--let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1)
|
|
--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
|
|
CREATE SEQUENCE s;
|
|
--disable_ps2_protocol
|
|
SELECT NEXTVAL(s);
|
|
--enable_ps2_protocol
|
|
flush binary logs;
|
|
DROP SEQUENCE s;
|
|
--exec $MYSQL_BINLOG $datadir/$binlog_file | $MYSQL test
|
|
DROP SEQUENCE s;
|
|
|
|
--sync_slave_with_master
|
|
|
|
--connection master
|
|
|
|
|
|
--source include/rpl_end.inc
|