Skip to content

Commit

Permalink
MDEV-10518: Large wsrep_gtid_domain_id may break IST
Browse files Browse the repository at this point in the history
wsrep_gtid_domain_id was incorrectly being parsed and stored
as a signed long number on the joiner node.
  • Loading branch information
Nirbhay Choubey committed Aug 23, 2016
1 parent 3ac0721 commit 2024cdd
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 3 deletions.
74 changes: 74 additions & 0 deletions mysql-test/suite/galera/r/mdev_10518.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# On node_1
list of GTID variables :
gtid_domain_id 1
gtid_binlog_pos
gtid_binlog_state
gtid_current_pos
gtid_slave_pos
wsrep_gtid_domain_id 4294967295
wsrep_gtid_mode 1
# On node_2
list of GTID variables :
gtid_domain_id 2
gtid_binlog_pos
gtid_binlog_state
gtid_current_pos
gtid_slave_pos
wsrep_gtid_domain_id 4294967295
wsrep_gtid_mode 1
# On node_1
CREATE TABLE t1(i INT) ENGINE=INNODB;
CREATE TABLE t2(i INT) ENGINE=MEMORY;
INSERT INTO t1 VALUES(1);
SELECT * FROM t1;
i
1
SELECT * FROM t2;
i
list of GTID variables :
gtid_domain_id 1
gtid_binlog_pos 4294967295-1-3
gtid_binlog_state 4294967295-1-3
gtid_current_pos 4294967295-1-3
gtid_slave_pos
wsrep_gtid_domain_id 4294967295
wsrep_gtid_mode 1
# On node_2
SELECT * FROM t1;
i
1
list of GTID variables :
gtid_domain_id 2
gtid_binlog_pos 4294967295-1-3
gtid_binlog_state 4294967295-1-3
gtid_current_pos
gtid_slave_pos
wsrep_gtid_domain_id 4294967295
wsrep_gtid_mode 1
# On node_1
INSERT INTO t2 VALUES(1);
SELECT * FROM t2;
i
1
list of GTID variables :
gtid_domain_id 1
gtid_binlog_pos 1-1-1,4294967295-1-3
gtid_binlog_state 1-1-1,4294967295-1-3
gtid_current_pos 1-1-1,4294967295-1-3
gtid_slave_pos
wsrep_gtid_domain_id 4294967295
wsrep_gtid_mode 1
# On node_2
SELECT * FROM t2;
i
list of GTID variables :
gtid_domain_id 2
gtid_binlog_pos 4294967295-1-3
gtid_binlog_state 4294967295-1-3
gtid_current_pos
gtid_slave_pos
wsrep_gtid_domain_id 4294967295
wsrep_gtid_mode 1
# On node_1
DROP TABLE t1, t2;
# End of test
17 changes: 17 additions & 0 deletions mysql-test/suite/galera/t/mdev_10518.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
!include ../galera_2nodes.cnf

[mysqld]
log-bin
log-slave-updates

[mysqld.1]
gtid_domain_id=1
wsrep_gtid_mode=ON
# Maximum allowed wsrep_gtid_domain_id.
wsrep_gtid_domain_id=4294967295

[mysqld.2]
gtid_domain_id=2
wsrep_gtid_mode=ON
#wsrep_gitd_domain_id value will be inherited from donor node (mysqld.1)
#wsrep_gitd_domain_id=X
53 changes: 53 additions & 0 deletions mysql-test/suite/galera/t/mdev_10518.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Test for @@wsrep_gtid_mode and @@wsrep_gtid_domain_id variables
#
# When @@wsrep_gtid_mode=ON, all DDL/DML commands and transactions that
# are meant to be replicated over Galera cluster nodes are tagged with
# galera gtid_domain_id (@@wsrep_gtid_domain_id), while others are tagged
# with the local domain_id (@@gtid_domain_id).

--source include/galera_cluster.inc
--source include/have_innodb.inc

--echo # On node_1
--connection node_1
# print initial GTIDs
source include/print_gtid.inc;

--echo # On node_2
--connection node_2
# print initial GTIDs
source include/print_gtid.inc;

--echo # On node_1
--connection node_1
CREATE TABLE t1(i INT) ENGINE=INNODB;
CREATE TABLE t2(i INT) ENGINE=MEMORY;
INSERT INTO t1 VALUES(1);
SELECT * FROM t1;
SELECT * FROM t2;
source include/print_gtid.inc;

--echo # On node_2
--connection node_2
SELECT * FROM t1;
source include/print_gtid.inc;

--echo # On node_1
--connection node_1
INSERT INTO t2 VALUES(1);
SELECT * FROM t2;
source include/print_gtid.inc;

--echo # On node_2
--connection node_2
SELECT * FROM t2;
source include/print_gtid.inc;

--echo # On node_1
--connection node_1
# Cleanup
DROP TABLE t1, t2;

--source include/galera_end.inc
--echo # End of test

6 changes: 3 additions & 3 deletions sql/wsrep_sst.cc
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static void* sst_joiner_thread (void* a)
} else {
// Scan state ID first followed by wsrep_gtid_domain_id.
char uuid[512];
long int domain_id;
unsigned long int domain_id;
size_t len= pos - out + 1;

if (len > sizeof(uuid)) goto err; // safety check
Expand All @@ -491,11 +491,11 @@ static void* sst_joiner_thread (void* a)
else if (wsrep_gtid_mode)
{
errno= 0; /* Reset the errno */
domain_id= strtol(pos + 1, NULL, 10);
domain_id= strtoul(pos + 1, NULL, 10);
err= errno;

/* Check if we received a valid gtid_domain_id. */
if (err == EINVAL || err == ERANGE || domain_id < 0x0 || domain_id > 0xFFFF)
if (err == EINVAL || err == ERANGE)
{
WSREP_ERROR("Failed to get donor wsrep_gtid_domain_id.");
err= EINVAL;
Expand Down

0 comments on commit 2024cdd

Please sign in to comment.