Skip to content

Commit 05a4996

Browse files
Jan Lindströmsysprg
authored andcommitted
MDEV-25978 : rsync SST does not work with custom binlog name
wsrep_sst_common did not correctly set name for binlog index file if custom binlog name was used and this name was not added to script command line. Added test case for both log_basename and log_binlog.
1 parent 1deb630 commit 05a4996

8 files changed

+259
-6
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
connection node_1;
2+
connection node_2;
3+
Performing State Transfer on a server that has been shut down cleanly and restarted
4+
connection node_1;
5+
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
6+
SET AUTOCOMMIT=OFF;
7+
START TRANSACTION;
8+
INSERT INTO t1 VALUES ('node1_committed_before');
9+
INSERT INTO t1 VALUES ('node1_committed_before');
10+
INSERT INTO t1 VALUES ('node1_committed_before');
11+
INSERT INTO t1 VALUES ('node1_committed_before');
12+
INSERT INTO t1 VALUES ('node1_committed_before');
13+
COMMIT;
14+
connection node_2;
15+
SET AUTOCOMMIT=OFF;
16+
START TRANSACTION;
17+
INSERT INTO t1 VALUES ('node2_committed_before');
18+
INSERT INTO t1 VALUES ('node2_committed_before');
19+
INSERT INTO t1 VALUES ('node2_committed_before');
20+
INSERT INTO t1 VALUES ('node2_committed_before');
21+
INSERT INTO t1 VALUES ('node2_committed_before');
22+
COMMIT;
23+
Shutting down server ...
24+
connection node_1;
25+
SET AUTOCOMMIT=OFF;
26+
START TRANSACTION;
27+
INSERT INTO t1 VALUES ('node1_committed_during');
28+
INSERT INTO t1 VALUES ('node1_committed_during');
29+
INSERT INTO t1 VALUES ('node1_committed_during');
30+
INSERT INTO t1 VALUES ('node1_committed_during');
31+
INSERT INTO t1 VALUES ('node1_committed_during');
32+
COMMIT;
33+
START TRANSACTION;
34+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
35+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
36+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
37+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
38+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
39+
connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1;
40+
SET AUTOCOMMIT=OFF;
41+
START TRANSACTION;
42+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
43+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
44+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
45+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
46+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
47+
connection node_2;
48+
Starting server ...
49+
SET AUTOCOMMIT=OFF;
50+
START TRANSACTION;
51+
INSERT INTO t1 VALUES ('node2_committed_after');
52+
INSERT INTO t1 VALUES ('node2_committed_after');
53+
INSERT INTO t1 VALUES ('node2_committed_after');
54+
INSERT INTO t1 VALUES ('node2_committed_after');
55+
INSERT INTO t1 VALUES ('node2_committed_after');
56+
COMMIT;
57+
connection node_1;
58+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
59+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
60+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
61+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
62+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
63+
COMMIT;
64+
SET AUTOCOMMIT=OFF;
65+
START TRANSACTION;
66+
INSERT INTO t1 VALUES ('node1_committed_after');
67+
INSERT INTO t1 VALUES ('node1_committed_after');
68+
INSERT INTO t1 VALUES ('node1_committed_after');
69+
INSERT INTO t1 VALUES ('node1_committed_after');
70+
INSERT INTO t1 VALUES ('node1_committed_after');
71+
COMMIT;
72+
connection node_1a_galera_st_shutdown_slave;
73+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
74+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
75+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
76+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
77+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
78+
ROLLBACK;
79+
SELECT COUNT(*) = 35 FROM t1;
80+
COUNT(*) = 35
81+
1
82+
SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
83+
COUNT(*) = 0
84+
1
85+
COMMIT;
86+
SET AUTOCOMMIT=ON;
87+
connection node_1;
88+
SELECT COUNT(*) = 35 FROM t1;
89+
COUNT(*) = 35
90+
1
91+
SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
92+
COUNT(*) = 0
93+
1
94+
DROP TABLE t1;
95+
COMMIT;
96+
SET AUTOCOMMIT=ON;
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
connection node_1;
2+
connection node_2;
3+
Performing State Transfer on a server that has been shut down cleanly and restarted
4+
connection node_1;
5+
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
6+
SET AUTOCOMMIT=OFF;
7+
START TRANSACTION;
8+
INSERT INTO t1 VALUES ('node1_committed_before');
9+
INSERT INTO t1 VALUES ('node1_committed_before');
10+
INSERT INTO t1 VALUES ('node1_committed_before');
11+
INSERT INTO t1 VALUES ('node1_committed_before');
12+
INSERT INTO t1 VALUES ('node1_committed_before');
13+
COMMIT;
14+
connection node_2;
15+
SET AUTOCOMMIT=OFF;
16+
START TRANSACTION;
17+
INSERT INTO t1 VALUES ('node2_committed_before');
18+
INSERT INTO t1 VALUES ('node2_committed_before');
19+
INSERT INTO t1 VALUES ('node2_committed_before');
20+
INSERT INTO t1 VALUES ('node2_committed_before');
21+
INSERT INTO t1 VALUES ('node2_committed_before');
22+
COMMIT;
23+
Shutting down server ...
24+
connection node_1;
25+
SET AUTOCOMMIT=OFF;
26+
START TRANSACTION;
27+
INSERT INTO t1 VALUES ('node1_committed_during');
28+
INSERT INTO t1 VALUES ('node1_committed_during');
29+
INSERT INTO t1 VALUES ('node1_committed_during');
30+
INSERT INTO t1 VALUES ('node1_committed_during');
31+
INSERT INTO t1 VALUES ('node1_committed_during');
32+
COMMIT;
33+
START TRANSACTION;
34+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
35+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
36+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
37+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
38+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
39+
connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1;
40+
SET AUTOCOMMIT=OFF;
41+
START TRANSACTION;
42+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
43+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
44+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
45+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
46+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
47+
connection node_2;
48+
Starting server ...
49+
SET AUTOCOMMIT=OFF;
50+
START TRANSACTION;
51+
INSERT INTO t1 VALUES ('node2_committed_after');
52+
INSERT INTO t1 VALUES ('node2_committed_after');
53+
INSERT INTO t1 VALUES ('node2_committed_after');
54+
INSERT INTO t1 VALUES ('node2_committed_after');
55+
INSERT INTO t1 VALUES ('node2_committed_after');
56+
COMMIT;
57+
connection node_1;
58+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
59+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
60+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
61+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
62+
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
63+
COMMIT;
64+
SET AUTOCOMMIT=OFF;
65+
START TRANSACTION;
66+
INSERT INTO t1 VALUES ('node1_committed_after');
67+
INSERT INTO t1 VALUES ('node1_committed_after');
68+
INSERT INTO t1 VALUES ('node1_committed_after');
69+
INSERT INTO t1 VALUES ('node1_committed_after');
70+
INSERT INTO t1 VALUES ('node1_committed_after');
71+
COMMIT;
72+
connection node_1a_galera_st_shutdown_slave;
73+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
74+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
75+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
76+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
77+
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
78+
ROLLBACK;
79+
SELECT COUNT(*) = 35 FROM t1;
80+
COUNT(*) = 35
81+
1
82+
SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
83+
COUNT(*) = 0
84+
1
85+
COMMIT;
86+
SET AUTOCOMMIT=ON;
87+
connection node_1;
88+
SELECT COUNT(*) = 35 FROM t1;
89+
COUNT(*) = 35
90+
1
91+
SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
92+
COUNT(*) = 0
93+
1
94+
DROP TABLE t1;
95+
COMMIT;
96+
SET AUTOCOMMIT=ON;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
!include ../galera_2nodes.cnf
2+
3+
[mysqld]
4+
wsrep_sst_method=rsync
5+
6+
[mysqld.1]
7+
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'
8+
log_bin=server1_binlog
9+
10+
[mysqld.2]
11+
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
12+
log_bin=server2_binlog
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--source include/galera_cluster.inc
2+
3+
--let $node_1=node_1
4+
--let $node_2=node_2
5+
--source include/auto_increment_offset_save.inc
6+
7+
--source suite/galera/include/galera_st_shutdown_slave.inc
8+
9+
--source include/auto_increment_offset_restore.inc
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
!include ../galera_2nodes.cnf
2+
3+
[mysqld]
4+
wsrep_sst_method=rsync
5+
6+
[mysqld.1]
7+
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'
8+
log_basename=server1
9+
log_bin
10+
11+
[mysqld.2]
12+
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
13+
log_basename=server2
14+
log_bin
15+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--source include/galera_cluster.inc
2+
3+
--let $node_1=node_1
4+
--let $node_2=node_2
5+
--source include/auto_increment_offset_save.inc
6+
7+
--source suite/galera/include/galera_st_shutdown_slave.inc
8+
9+
--source include/auto_increment_offset_restore.inc

scripts/wsrep_sst_common.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,9 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then
465465
# the "-bin" suffix:
466466
readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin"
467467
else
468-
# Take the default name:
469-
readonly WSREP_SST_OPT_BINLOG='mysql-bin'
468+
# the default name, note that base of this name
469+
# is already defined above
470+
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index"
470471
fi
471472
fi
472473

@@ -549,9 +550,9 @@ get_binlog()
549550
# the "-bin" suffix:
550551
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index"
551552
else
552-
# If the base name not specified, then we take
553-
# the default name:
554-
readonly WSREP_SST_OPT_BINLOG_INDEX='mysql-bin.index'
553+
# the default name, note that base of this name
554+
# is already defined above
555+
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index"
555556
fi
556557
fi
557558
fi

sql/wsrep_sst.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,8 @@ static ssize_t sst_prepare_other (const char* method,
984984
{
985985
WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d",
986986
ret);
987+
if (binlog_opt_val) my_free(binlog_opt_val);
988+
return ret;
987989
}
988990

989991
make_wsrep_defaults_file();
@@ -1001,6 +1003,7 @@ static ssize_t sst_prepare_other (const char* method,
10011003
wsrep_defaults_file,
10021004
(int)getpid(),
10031005
binlog_opt_val, binlog_index_opt_val);
1006+
10041007
my_free(binlog_opt_val);
10051008
my_free(binlog_index_opt_val);
10061009

@@ -1658,6 +1661,7 @@ static int sst_donate_other (const char* method,
16581661
}
16591662

16601663
char* binlog_opt_val= NULL;
1664+
char* binlog_index_opt_val= NULL;
16611665

16621666
int ret;
16631667
if ((ret= generate_binlog_opt_val(&binlog_opt_val)))
@@ -1666,6 +1670,14 @@ static int sst_donate_other (const char* method,
16661670
return ret;
16671671
}
16681672

1673+
if ((ret= generate_binlog_index_opt_val(&binlog_index_opt_val)))
1674+
{
1675+
WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d",
1676+
ret);
1677+
if (binlog_opt_val) my_free(binlog_opt_val);
1678+
return ret;
1679+
}
1680+
16691681
make_wsrep_defaults_file();
16701682

16711683
ret= snprintf (cmd_str(), cmd_len,
@@ -1679,14 +1691,17 @@ static int sst_donate_other (const char* method,
16791691
WSREP_SST_OPT_GTID " '%s:%lld' "
16801692
WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'"
16811693
"%s"
1694+
"%s"
16821695
"%s",
16831696
method, addr, mysqld_port, mysqld_unix_port,
16841697
mysql_real_data_home,
16851698
wsrep_defaults_file,
16861699
uuid, (long long) seqno, wsrep_gtid_domain_id,
1687-
binlog_opt_val,
1700+
binlog_opt_val, binlog_index_opt_val,
16881701
bypass ? " " WSREP_SST_OPT_BYPASS : "");
1702+
16891703
my_free(binlog_opt_val);
1704+
my_free(binlog_index_opt_val);
16901705

16911706
if (ret < 0 || size_t(ret) >= cmd_len)
16921707
{

0 commit comments

Comments
 (0)