Skip to content

Commit a74fa57

Browse files
committed
MDEV-24903: mariabackup SST fails while adding --log-bin in startup command
Mariabackup SST fails if "--log-bin" option is added with no value to command line parameters at server startup. This is because the SST scripts do not correctly interpret the "--- log-bin" option without a value. This patch adds correct handling of the "--log-bin" parameter without value to the general part of the parameter parsing (for SST scripts) and fixes the problem. Also added a test that checks the correct operation of the server after the fix.
1 parent 4e825b0 commit a74fa57

File tree

7 files changed

+137
-42
lines changed

7 files changed

+137
-42
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
connection node_1;
2+
reset master;
3+
connection node_2;
4+
reset master;
5+
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
6+
INSERT INTO t1 VALUES (1);
7+
CREATE TABLE t2 (id INT) ENGINE=InnoDB;
8+
INSERT INTO t2 VALUES (1);
9+
INSERT INTO t2 VALUES (1);
10+
connection node_2;
11+
SELECT COUNT(*) = 1 FROM t1;
12+
COUNT(*) = 1
13+
1
14+
SELECT COUNT(*) = 2 FROM t2;
15+
COUNT(*) = 2
16+
1
17+
connection node_1;
18+
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
19+
include/show_binlog_events.inc
20+
Log_name Pos Event_type Server_id End_log_pos Info
21+
mysqld-bin.000001 # Gtid # # GTID #-#-#
22+
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
23+
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
24+
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
25+
mysqld-bin.000001 # Table_map # # table_id: # (test.t1)
26+
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
27+
mysqld-bin.000001 # Xid # # COMMIT /* XID */
28+
mysqld-bin.000001 # Gtid # # GTID #-#-#
29+
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
30+
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
31+
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
32+
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
33+
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
34+
mysqld-bin.000001 # Xid # # COMMIT /* XID */
35+
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
36+
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
37+
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
38+
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
39+
mysqld-bin.000001 # Xid # # COMMIT /* XID */
40+
mysqld-bin.000001 # Gtid # # GTID #-#-#
41+
mysqld-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
42+
connection node_2;
43+
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
44+
COUNT(*) = 2
45+
1
46+
include/show_binlog_events.inc
47+
Log_name Pos Event_type Server_id End_log_pos Info
48+
mysqld-bin.000001 # Gtid # # GTID #-#-#
49+
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
50+
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
51+
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
52+
mysqld-bin.000001 # Table_map # # table_id: # (test.t1)
53+
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
54+
mysqld-bin.000001 # Xid # # COMMIT /* XID */
55+
mysqld-bin.000001 # Gtid # # GTID #-#-#
56+
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
57+
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
58+
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
59+
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
60+
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
61+
mysqld-bin.000001 # Xid # # COMMIT /* XID */
62+
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
63+
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
64+
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
65+
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
66+
mysqld-bin.000001 # Xid # # COMMIT /* XID */
67+
mysqld-bin.000001 # Gtid # # GTID #-#-#
68+
mysqld-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
69+
DROP TABLE t1;
70+
DROP TABLE t2;
71+
#cleanup
72+
connection node_1;
73+
RESET MASTER;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--source include/galera_cluster.inc
2+
--source include/force_restart.inc
3+
4+
--connection node_1
5+
reset master;
6+
--connection node_2
7+
reset master;
8+
9+
#
10+
# Test Galera with --log-bin --log-slave-updates .
11+
# This way the actual MySQL binary log is used,
12+
# rather than Galera's own implementation
13+
#
14+
15+
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
16+
INSERT INTO t1 VALUES (1);
17+
18+
CREATE TABLE t2 (id INT) ENGINE=InnoDB;
19+
INSERT INTO t2 VALUES (1);
20+
INSERT INTO t2 VALUES (1);
21+
22+
--connection node_2
23+
SELECT COUNT(*) = 1 FROM t1;
24+
SELECT COUNT(*) = 2 FROM t2;
25+
26+
--connection node_1
27+
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
28+
--let $MASTER_MYPORT=$NODE_MYPORT_1
29+
--source include/show_binlog_events.inc
30+
31+
--connection node_2
32+
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
33+
--let $MASTER_MYPORT=$NODE_MYPORT_2
34+
--source include/show_binlog_events.inc
35+
36+
DROP TABLE t1;
37+
DROP TABLE t2;
38+
39+
--echo #cleanup
40+
--connection node_1
41+
RESET MASTER;
42+
Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1 @@
1-
--source include/galera_cluster.inc
2-
--source include/force_restart.inc
3-
4-
--connection node_1
5-
reset master;
6-
--connection node_2
7-
reset master;
8-
9-
#
10-
# Test Galera with --log-bin --log-slave-updates .
11-
# This way the actual MySQL binary log is used,
12-
# rather than Galera's own implementation
13-
#
14-
15-
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
16-
INSERT INTO t1 VALUES (1);
17-
18-
CREATE TABLE t2 (id INT) ENGINE=InnoDB;
19-
INSERT INTO t2 VALUES (1);
20-
INSERT INTO t2 VALUES (1);
21-
22-
--connection node_2
23-
SELECT COUNT(*) = 1 FROM t1;
24-
SELECT COUNT(*) = 2 FROM t2;
25-
26-
--connection node_1
27-
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
28-
--let $MASTER_MYPORT=$NODE_MYPORT_1
29-
--source include/show_binlog_events.inc
30-
31-
--connection node_2
32-
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
33-
--let $MASTER_MYPORT=$NODE_MYPORT_2
34-
--source include/show_binlog_events.inc
35-
36-
DROP TABLE t1;
37-
DROP TABLE t2;
38-
39-
--echo #cleanup
40-
--connection node_1
41-
RESET MASTER;
42-
1+
--source galera_log_bin.inc
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--log-slave-updates --log-bin
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=mariabackup
5+
wsrep_sst_auth="root:"
6+
7+
[mysqld.1]
8+
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'
9+
10+
[mysqld.2]
11+
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
12+
13+
[sst]
14+
transferfmt=@ENV.MTR_GALERA_TFMT
15+
streamfmt=xbstream
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--source include/have_mariabackup.inc
2+
--source galera_log_bin.inc

scripts/wsrep_sst_common.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ case "$1" in
212212
"$option" != "--port" && \
213213
"$option" != "--socket" ]]; then
214214
value=${1#*=}
215+
if [ "$value" == "$1" ]; then
216+
value=""
217+
fi
215218
case "$option" in
216219
'--innodb-data-home-dir')
217220
if [ -z "$INNODB_DATA_HOME_DIR_ARG" ]; then

0 commit comments

Comments
 (0)