Skip to content

Commit 44c4b23

Browse files
committed
MDEV-8496: gtid_ignore_duplicates treats gtid_seq_no as 32-bit
--gtid-ignore-duplicates was comparing sequence numbers as 32-bit, so after 2**32 transactions things would start to fail.
1 parent b89de2b commit 44c4b23

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

mysql-test/suite/multi_source/gtid_ignore_duplicates.result

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,39 @@ a
381381
50
382382
SET GLOBAL slave_exec_mode=@old_slave_mode;
383383
SET GLOBAL gtid_strict_mode=@old_strict;
384+
*** MDEV-8496: gtid_ignore_duplicates treats gtid_seq_no as 32-bit ***
385+
SET @old_domain= @@SESSION.gtid_domain_id;
386+
SET SESSION gtid_domain_id=102;
387+
SET SESSION gtid_seq_no=4294967294;
388+
INSERT INTO t1 VALUES (60);
389+
INSERT INTO t1 VALUES (61);
390+
INSERT INTO t1 VALUES (62);
391+
SET SESSION gtid_domain_id= @old_domain;
392+
include/save_master_gtid.inc
393+
include/sync_with_master_gtid.inc
394+
SELECT * FROM t1 WHERE a >= 60 ORDER BY a;
395+
a
396+
60
397+
61
398+
62
399+
SET default_master_connection = "c2b";
400+
include/sync_with_master_gtid.inc
401+
SET default_master_connection = "a2b";
402+
include/sync_with_master_gtid.inc
403+
SELECT * FROM t1 WHERE a >= 60 ORDER BY a;
404+
a
405+
60
406+
61
407+
62
408+
SET default_master_connection = "b2c";
409+
include/sync_with_master_gtid.inc
410+
SET default_master_connection = "a2c";
411+
include/sync_with_master_gtid.inc
412+
SELECT * FROM t1 WHERE a >= 60 ORDER BY a;
413+
a
414+
60
415+
61
416+
62
384417
SET GLOBAL gtid_domain_id=0;
385418
STOP ALL SLAVES;
386419
Warnings:

mysql-test/suite/multi_source/gtid_ignore_duplicates.test

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,40 @@ SET GLOBAL slave_exec_mode=@old_slave_mode;
366366
SET GLOBAL gtid_strict_mode=@old_strict;
367367

368368

369+
--echo *** MDEV-8496: gtid_ignore_duplicates treats gtid_seq_no as 32-bit ***
370+
371+
--connection server_1
372+
SET @old_domain= @@SESSION.gtid_domain_id;
373+
SET SESSION gtid_domain_id=102;
374+
SET SESSION gtid_seq_no=4294967294;
375+
INSERT INTO t1 VALUES (60);
376+
INSERT INTO t1 VALUES (61);
377+
INSERT INTO t1 VALUES (62);
378+
# The bug was an overflow, the seq_no value 4294967296 (2**32) was treated
379+
# as 0, causing the last transaction to be ignored.
380+
SET SESSION gtid_domain_id= @old_domain;
381+
--source include/save_master_gtid.inc
382+
383+
--connection server_4
384+
--source include/sync_with_master_gtid.inc
385+
SELECT * FROM t1 WHERE a >= 60 ORDER BY a;
386+
387+
--connection server_2
388+
SET default_master_connection = "c2b";
389+
--source include/sync_with_master_gtid.inc
390+
SET default_master_connection = "a2b";
391+
--source include/sync_with_master_gtid.inc
392+
SELECT * FROM t1 WHERE a >= 60 ORDER BY a;
393+
394+
--connection server_3
395+
SET default_master_connection = "b2c";
396+
--source include/sync_with_master_gtid.inc
397+
SET default_master_connection = "a2c";
398+
--source include/sync_with_master_gtid.inc
399+
SELECT * FROM t1 WHERE a >= 60 ORDER BY a;
400+
401+
402+
369403
# Clean up.
370404
--connection server_1
371405
SET GLOBAL gtid_domain_id=0;

sql/rpl_gtid.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int
117117
rpl_slave_state::check_duplicate_gtid(rpl_gtid *gtid, rpl_group_info *rgi)
118118
{
119119
uint32 domain_id= gtid->domain_id;
120-
uint32 seq_no= gtid->seq_no;
120+
uint64 seq_no= gtid->seq_no;
121121
rpl_slave_state::element *elem;
122122
int res;
123123
bool did_enter_cond= false;

0 commit comments

Comments
 (0)