1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
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;
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
|