Skip to content

Commit 5a30427

Browse files
author
Jaideep Karande
committed
Bug#36446250: Backport BUG#36280130 to 8.0.38
Details of "Bug#36280130: HA Secondaries lagging, unable to recover after failover" Issue: Currently, the sequence number increases during garbage collection, even though no event is logged. Reason: This increment prevents running transactions before and after garbage collection in parallel. This is due to separate certification databases after garbage collection. Proposed Solution: Skip the sequence number increment during garbage collection. Instead, just update the last_committed variable to maintain the parallel execution restriction. This update ensures the necessary distinction between pre- and post-garbage collection transactions. Benefits: Simplifies the process by eliminating unnecessary sequence number updates. Maintains the intended behavior of preventing parallel execution across garbage collection boundaries. Change-Id: Ia82b5c3b94edb29addd4dd918dccac5f44293970
1 parent 71792a5 commit 5a30427

15 files changed

+605
-49
lines changed

mysql-test/suite/group_replication/r/gr_create_table_as_select.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CREATE TABLE t5 (c1 INT NOT NULL) AS SELECT * FROM t1;
3333
############################################################
3434
include/rpl_sync.inc
3535
[connection server2]
36-
include/include/assert_logical_timestamps.inc [0 0;0 0;2 3;3 4;4 5;5 6;6 7;7 8;8 9;9 10]
36+
include/include/assert_logical_timestamps.inc [0 0;1 2;2 3;3 4;4 5;5 6;6 7;7 8;8 9]
3737
Asserting all GTID transaction length information in 'server-relay-log-group_replication_applier.000002'
3838
Inspected 9 transactions, all with correct transaction length.
3939

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
include/group_replication.inc
2+
Warnings:
3+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
5+
[connection server1]
6+
#################################################################
7+
# 1. Add debug point to reduce certifier broadcast time to 1 second.
8+
# Bootstrap M1 and join M2.
9+
[connection server1]
10+
SET @@GLOBAL.DEBUG= '+d,group_replication_certifier_broadcast_thread_short_period';
11+
include/start_and_bootstrap_group_replication.inc
12+
[connection server2]
13+
SET @@GLOBAL.DEBUG= '+d,group_replication_certifier_broadcast_thread_short_period';
14+
SET @@GLOBAL.DEBUG= '+d,group_replication_certifier_garbage_collection_ran';
15+
include/start_group_replication.inc
16+
#################################################################
17+
# 2. Insert 5 rows.
18+
# Wait for garbage collector to run for every insert.
19+
[connection server1]
20+
CREATE TABLE t1(c1 INT PRIMARY KEY);
21+
[connection server2]
22+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
23+
[connection server1]
24+
INSERT INTO t1 VALUES (1);
25+
[connection server2]
26+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
27+
[connection server1]
28+
INSERT INTO t1 VALUES (2);
29+
[connection server2]
30+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
31+
[connection server1]
32+
INSERT INTO t1 VALUES (3);
33+
[connection server2]
34+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
35+
[connection server1]
36+
INSERT INTO t1 VALUES (4);
37+
[connection server2]
38+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
39+
[connection server1]
40+
INSERT INTO t1 VALUES (5);
41+
include/rpl_sync.inc
42+
#################################################################
43+
# 3. Assert sequence numbers and last_committed are correct.
44+
# Verify no gaps in sequence number.
45+
[connection server2]
46+
include/include/assert_logical_timestamps.inc [0 0;1 2;2 3;3 4;4 5;5 6;6 7]
47+
#################################################################
48+
# 4. Run 5 DDLs.
49+
# Wait for garbage collector to run for every statement.
50+
[connection server1]
51+
[connection server2]
52+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
53+
[connection server1]
54+
CREATE TABLE tt1(c1 INT PRIMARY KEY);
55+
[connection server2]
56+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
57+
[connection server1]
58+
CREATE TABLE tt2(c1 INT PRIMARY KEY);
59+
[connection server2]
60+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
61+
[connection server1]
62+
CREATE TABLE tt3(c1 INT PRIMARY KEY);
63+
[connection server2]
64+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
65+
[connection server1]
66+
CREATE TABLE tt4(c1 INT PRIMARY KEY);
67+
[connection server2]
68+
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_certifier_garbage_collection_finished";
69+
[connection server1]
70+
CREATE TABLE tt5(c1 INT PRIMARY KEY);
71+
include/rpl_sync.inc
72+
#################################################################
73+
# 5. Assert sequence numbers and last_committed are correct.
74+
# Verify no gaps in sequence number.
75+
[connection server2]
76+
include/include/assert_logical_timestamps.inc [0 0;1 2;2 3;3 4;4 5;5 6;6 7;7 8;8 9;9 10;10 11;11 12]
77+
#################################################################
78+
# 6. Stop the group.
79+
[connection server2]
80+
include/stop_group_replication.inc
81+
SET @@GLOBAL.DEBUG= '-d,group_replication_certifier_garbage_collection_ran';
82+
SET @@GLOBAL.DEBUG= '-d,group_replication_certifier_broadcast_thread_short_period';
83+
SET DEBUG_SYNC= 'RESET';
84+
[connection server1]
85+
include/stop_group_replication.inc
86+
SET @@GLOBAL.DEBUG= '-d,group_replication_certifier_broadcast_thread_short_period';
87+
#################################################################
88+
# 7. Add debug point to disable certification info garbage collection.
89+
# Bootstrap M1 and join M2.
90+
[connection server1]
91+
SET @@GLOBAL.DEBUG= '+d,group_replication_do_not_clear_certification_database';
92+
SET @@GLOBAL.DEBUG= '+d,group_replication_certifier_broadcast_thread_big_period';
93+
include/start_and_bootstrap_group_replication.inc
94+
[connection server2]
95+
SET @@GLOBAL.DEBUG= '+d,group_replication_do_not_clear_certification_database';
96+
SET @@GLOBAL.DEBUG= '+d,group_replication_certifier_broadcast_thread_big_period';
97+
include/start_group_replication.inc
98+
#################################################################
99+
# 8. Insert 10 rows.
100+
[connection server1]
101+
[connection server1]
102+
INSERT INTO test.t1 VALUES (6);
103+
[connection server1]
104+
INSERT INTO test.t1 VALUES (7);
105+
[connection server1]
106+
INSERT INTO test.t1 VALUES (8);
107+
[connection server1]
108+
INSERT INTO test.t1 VALUES (9);
109+
[connection server1]
110+
INSERT INTO test.t1 VALUES (10);
111+
[connection server1]
112+
INSERT INTO test.t1 VALUES (11);
113+
[connection server1]
114+
INSERT INTO test.t1 VALUES (12);
115+
[connection server1]
116+
INSERT INTO test.t1 VALUES (13);
117+
[connection server1]
118+
INSERT INTO test.t1 VALUES (14);
119+
[connection server1]
120+
INSERT INTO test.t1 VALUES (15);
121+
include/rpl_sync.inc
122+
[connection server2]
123+
include/include/assert_logical_timestamps.inc [0 0;1 2;1 3;1 4;1 5;1 6;1 7;1 8;1 9;1 10;1 11]
124+
#################################################################
125+
# 9. Run 5 DDLs.
126+
[connection server1]
127+
DROP TABLE tt1;
128+
DROP TABLE tt2;
129+
DROP TABLE tt3;
130+
DROP TABLE tt4;
131+
DROP TABLE tt5;
132+
include/rpl_sync.inc
133+
[connection server2]
134+
include/include/assert_logical_timestamps.inc [0 0;1 2;1 3;1 4;1 5;1 6;1 7;1 8;1 9;1 10;1 11;11 12;12 13;13 14;14 15;15 16]
135+
#################################################################
136+
# 10. Cleanup.
137+
[connection server1]
138+
DROP TABLE t1;
139+
include/rpl_sync.inc
140+
[connection server2]
141+
include/stop_group_replication.inc
142+
SET @@GLOBAL.DEBUG= '-d,group_replication_do_not_clear_certification_database';
143+
SET @@GLOBAL.DEBUG= '-d,group_replication_certifier_broadcast_thread_big_period';
144+
[connection server1]
145+
include/stop_group_replication.inc
146+
SET @@GLOBAL.DEBUG= '-d,group_replication_do_not_clear_certification_database';
147+
SET @@GLOBAL.DEBUG= '-d,group_replication_certifier_broadcast_thread_big_period';
148+
include/group_replication_end.inc

mysql-test/suite/group_replication/r/gr_parallel_applier_indexes.result

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ Matching lines are:
4040
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4141
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4242
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
43-
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=4 sequence_number=5 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
44-
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=5 sequence_number=6 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
45-
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=5 sequence_number=7 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
46-
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=6 sequence_number=8 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
43+
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=1 sequence_number=2 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
44+
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=2 sequence_number=3 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
45+
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=2 sequence_number=4 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
46+
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=3 sequence_number=5 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4747
Occurrences of 'last_committed' in the input file: 8
48-
include/include/assert_logical_timestamps.inc [0 0;0 0;0 0;0 0;4 5;5 6;5 7;6 8]
48+
include/include/assert_logical_timestamps.inc [0 0;0 0;0 0;1 2;2 3;2 4;3 5]
4949
Asserting all GTID transaction length information in 'server-relay-log-group_replication_applier.000002'
5050
Inspected 7 transactions, all with correct transaction length.
5151

@@ -82,11 +82,11 @@ include/rpl_sync.inc
8282
Matching lines are:
8383
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
8484
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
85-
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=2 sequence_number=3 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
86-
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=2 sequence_number=4 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
87-
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=4 sequence_number=5 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
85+
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=1 sequence_number=2 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
86+
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=1 sequence_number=3 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
87+
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=3 sequence_number=4 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
8888
Occurrences of 'last_committed' in the input file: 5
89-
include/include/assert_logical_timestamps.inc [0 0;0 0;2 3;2 4;4 5]
89+
include/include/assert_logical_timestamps.inc [0 0;1 2;1 3;3 4]
9090
Asserting all GTID transaction length information in 'server-relay-log-group_replication_applier.000003'
9191
Inspected 4 transactions, all with correct transaction length.
9292

@@ -127,12 +127,12 @@ include/rpl_sync.inc
127127
Matching lines are:
128128
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
129129
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
130-
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=2 sequence_number=3 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
131-
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=2 sequence_number=4 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
132-
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=4 sequence_number=5 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
133-
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=6 sequence_number=7 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
130+
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=1 sequence_number=2 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
131+
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=1 sequence_number=3 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
132+
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=3 sequence_number=4 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
133+
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=4 sequence_number=5 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
134134
Occurrences of 'last_committed' in the input file: 6
135-
include/include/assert_logical_timestamps.inc [0 0;0 0;2 3;2 4;4 5;6 7]
135+
include/include/assert_logical_timestamps.inc [0 0;1 2;1 3;3 4;4 5]
136136
Asserting all GTID transaction length information in 'server-relay-log-group_replication_applier.000003'
137137
Inspected 5 transactions, all with correct transaction length.
138138

@@ -145,9 +145,9 @@ Matching lines are:
145145
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=1 sequence_number=2 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
146146
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=2 sequence_number=3 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
147147
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=1 sequence_number=4 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
148-
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=5 sequence_number=6 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
148+
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=4 sequence_number=5 rbr_only=yes original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
149149
Occurrences of 'last_committed' in the input file: 5
150-
include/include/assert_logical_timestamps.inc [0 0;1 2;2 3;1 4;5 6]
150+
include/include/assert_logical_timestamps.inc [1 2;2 3;1 4;4 5]
151151
Asserting all GTID transaction length information in 'server-relay-log-group_replication_applier.000003'
152152
Inspected 4 transactions, all with correct transaction length.
153153

mysql-test/suite/group_replication/r/gr_parallel_applier_indexes_commit_order.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ include/rpl_sync.inc
124124

125125
# Assert parallel indexes, the 4 groups of transactions
126126
# must be parallel.
127-
include/include/assert_logical_timestamps.inc [0 0;0 0;2 3;3 4;3 5;3 6;3 7;3 8;3 9;3 10;3 11;3 12;3 13;3 14;3 15;3 16;3 17;3 18;3 19]
127+
include/include/assert_logical_timestamps.inc [0 0;1 2;2 3;2 4;2 5;2 6;2 7;2 8;2 9;2 10;2 11;2 12;2 13;2 14;2 15;2 16;2 17;2 18]
128128
include/stop_group_replication.inc
129129

130130
# Binary log will be reapplied one by one later through mysql. The
@@ -171,7 +171,7 @@ DROP TABLE t1;
171171

172172
# Assert parallel indexes, the 4 groups of transactions
173173
# must be parallel.
174-
include/include/assert_logical_timestamps.inc [0 0;0 0;0 0;3 4;4 5;4 6;4 7;4 8;4 9;4 10;4 11;4 12;4 13;4 14;4 15;4 16;4 17;4 18;4 19;4 20]
174+
include/include/assert_logical_timestamps.inc [0 0;0 0;1 2;2 3;2 4;2 5;2 6;2 7;2 8;2 9;2 10;2 11;2 12;2 13;2 14;2 15;2 16;2 17;2 18]
175175
include/stop_group_replication.inc
176176

177177
# Binary log will be reapplied one by one later through mysql. The

mysql-test/suite/group_replication/r/gr_parallel_applier_sequential_indexes.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ Matching lines are:
4343
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4444
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4545
#time# ##:##:## server id 4 end_log_pos ## GTID last_committed=0 sequence_number=0 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
46+
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=1 sequence_number=2 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
47+
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=2 sequence_number=3 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
48+
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=3 sequence_number=4 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4649
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=4 sequence_number=5 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4750
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=5 sequence_number=6 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
4851
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=6 sequence_number=7 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
49-
#time# ##:##:## server id 1 end_log_pos ## GTID last_committed=7 sequence_number=8 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
50-
#time# ##:##:## server id 2 end_log_pos ## GTID last_committed=8 sequence_number=9 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
51-
#time# ##:##:## server id 3 end_log_pos ## GTID last_committed=9 sequence_number=10 rbr_only=no original_committed_timestamp=##:##:## immediate_commit_timestamp=##:##:## transaction_length=#
5252
Occurrences of 'last_committed' in the input file: 10
53-
include/include/assert_logical_timestamps.inc [0 0;0 0;0 0;0 0;4 5;5 6;6 7;7 8;8 9;9 10]
53+
include/include/assert_logical_timestamps.inc [0 0;0 0;0 0;1 2;2 3;3 4;4 5;5 6;6 7]
5454
Asserting all GTID transaction length information in 'server-relay-log-group_replication_applier.000002'
5555
Inspected 9 transactions, all with correct transaction length.
5656

0 commit comments

Comments
 (0)