Skip to content

Commit 9ec475c

Browse files
sciascidJan Lindström
authored andcommitted
MDEV-29171 changing the value of wsrep_gtid_domain_id with full cluster restart fails on some nodes
Fix `wsrep_init_gtid()` to avoid overwriting the domain id received during state transfer. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
1 parent 179c283 commit 9ec475c

File tree

4 files changed

+141
-1
lines changed

4 files changed

+141
-1
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
connection node_2;
2+
connection node_1;
3+
connection node_1;
4+
select @@wsrep_gtid_domain_id,@@wsrep_node_name;
5+
@@wsrep_gtid_domain_id @@wsrep_node_name
6+
100 node1
7+
connection node_2;
8+
select @@wsrep_gtid_domain_id,@@wsrep_node_name;
9+
@@wsrep_gtid_domain_id @@wsrep_node_name
10+
100 node2
11+
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
12+
connection node_3;
13+
select @@wsrep_gtid_domain_id,@@wsrep_node_name;
14+
@@wsrep_gtid_domain_id @@wsrep_node_name
15+
100 node3
16+
connection node_3;
17+
connection node_2;
18+
connection node_1;
19+
connection node_1;
20+
# restart: --wsrep_new_cluster --wsrep_gtid_domain_id=200
21+
show variables like 'wsrep_gtid_domain_id';
22+
Variable_name Value
23+
wsrep_gtid_domain_id 200
24+
connection node_2;
25+
# restart
26+
show variables like 'wsrep_gtid_domain_id';
27+
Variable_name Value
28+
wsrep_gtid_domain_id 200
29+
connection node_3;
30+
# restart: --wsrep_sst_donor=node2
31+
show variables like 'wsrep_gtid_domain_id';
32+
Variable_name Value
33+
wsrep_gtid_domain_id 200
34+
connection node_1;
35+
set global wsrep_gtid_domain_id=100;
36+
connection node_2;
37+
set global wsrep_gtid_domain_id=100;
38+
CALL mtr.add_suppression("WSREP: Ignoring server id for non bootstrap node.");
39+
connection node_3;
40+
set global wsrep_gtid_domain_id=100;
41+
CALL mtr.add_suppression("WSREP: Ignoring server id for non bootstrap node.");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!include ../galera_3nodes.cnf
2+
3+
[mysqld.1]
4+
wsrep-node-name="node1"
5+
wsrep-gtid-mode=ON
6+
wsrep-gtid-domain-id=100
7+
8+
[mysqld.2]
9+
wsrep-node-name="node2"
10+
wsrep-gtid-mode=ON
11+
12+
[mysqld.3]
13+
wsrep-node-name="node3"
14+
wsrep-gtid-mode=ON
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#
2+
# MDEV-29171: changing the value of wsrep_gtid_domain_id
3+
# with full cluster restart fails on some nodes
4+
#
5+
6+
--source include/galera_cluster.inc
7+
--source include/have_innodb.inc
8+
9+
#
10+
# Initially wsrep gtid domain id is 100
11+
#
12+
--connection node_1
13+
select @@wsrep_gtid_domain_id,@@wsrep_node_name;
14+
15+
--connection node_2
16+
select @@wsrep_gtid_domain_id,@@wsrep_node_name;
17+
18+
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
19+
--connection node_3
20+
select @@wsrep_gtid_domain_id,@@wsrep_node_name;
21+
22+
23+
#
24+
# Shutdown all nodes
25+
#
26+
--connection node_3
27+
--source include/shutdown_mysqld.inc
28+
29+
--connection node_2
30+
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
31+
--source include/wait_condition.inc
32+
--source include/shutdown_mysqld.inc
33+
34+
--connection node_1
35+
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
36+
--source include/wait_condition.inc
37+
--source include/shutdown_mysqld.inc
38+
39+
40+
#
41+
# Bootstrap from node_1 and change wsrep_gtid_domain_id to 200
42+
#
43+
--connection node_1
44+
--let $restart_parameters = --wsrep_new_cluster --wsrep_gtid_domain_id=200
45+
--source include/start_mysqld.inc
46+
show variables like 'wsrep_gtid_domain_id';
47+
48+
49+
#
50+
# Restart node_2, expect that wsrep_gtid_domain_id has changed to 200
51+
#
52+
--connection node_2
53+
--let $restart_parameters =
54+
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
55+
--source include/start_mysqld.inc
56+
show variables like 'wsrep_gtid_domain_id';
57+
58+
59+
#
60+
# Restart node_3, select node_2 as donor
61+
# If bug is present, node_3 remains on domain id 100
62+
#
63+
--connection node_3
64+
--let $restart_parameters = --wsrep_sst_donor="node2"
65+
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect
66+
--source include/start_mysqld.inc
67+
# Expect domain id 200
68+
show variables like 'wsrep_gtid_domain_id';
69+
70+
71+
#
72+
# Cleanup
73+
#
74+
--connection node_1
75+
set global wsrep_gtid_domain_id=100;
76+
77+
--connection node_2
78+
set global wsrep_gtid_domain_id=100;
79+
CALL mtr.add_suppression("WSREP: Ignoring server id for non bootstrap node.");
80+
81+
--connection node_3
82+
set global wsrep_gtid_domain_id=100;
83+
CALL mtr.add_suppression("WSREP: Ignoring server id for non bootstrap node.");

sql/wsrep_mysqld.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,12 @@ static void wsrep_log_cb(wsrep::log::level level,
364364
void wsrep_init_gtid()
365365
{
366366
wsrep_server_gtid_t stored_gtid= wsrep_get_SE_checkpoint<wsrep_server_gtid_t>();
367+
// Domain id may have changed, use the one
368+
// received during state transfer.
369+
stored_gtid.domain_id= wsrep_gtid_server.domain_id;
367370
if (stored_gtid.server_id == 0)
368371
{
369372
rpl_gtid wsrep_last_gtid;
370-
stored_gtid.domain_id= wsrep_gtid_server.domain_id;
371373
if (mysql_bin_log.is_open() &&
372374
mysql_bin_log.lookup_domain_in_binlog_state(stored_gtid.domain_id,
373375
&wsrep_last_gtid))

0 commit comments

Comments
 (0)