Commit 2024cdda authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-10518: Large wsrep_gtid_domain_id may break IST

wsrep_gtid_domain_id was incorrectly being parsed and stored
as a signed long number on the joiner node.
parent 3ac0721a
# 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
!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
# 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
...@@ -477,7 +477,7 @@ static void* sst_joiner_thread (void* a) ...@@ -477,7 +477,7 @@ static void* sst_joiner_thread (void* a)
} else { } else {
// Scan state ID first followed by wsrep_gtid_domain_id. // Scan state ID first followed by wsrep_gtid_domain_id.
char uuid[512]; char uuid[512];
long int domain_id; unsigned long int domain_id;
size_t len= pos - out + 1; size_t len= pos - out + 1;
if (len > sizeof(uuid)) goto err; // safety check if (len > sizeof(uuid)) goto err; // safety check
...@@ -491,11 +491,11 @@ static void* sst_joiner_thread (void* a) ...@@ -491,11 +491,11 @@ static void* sst_joiner_thread (void* a)
else if (wsrep_gtid_mode) else if (wsrep_gtid_mode)
{ {
errno= 0; /* Reset the errno */ errno= 0; /* Reset the errno */
domain_id= strtol(pos + 1, NULL, 10); domain_id= strtoul(pos + 1, NULL, 10);
err= errno; err= errno;
/* Check if we received a valid gtid_domain_id. */ /* 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."); WSREP_ERROR("Failed to get donor wsrep_gtid_domain_id.");
err= EINVAL; err= EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment