Skip to content

Commit

Permalink
MDEV-24903: mariabackup SST fails while adding --log-bin in startup c…
Browse files Browse the repository at this point in the history
…ommand

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.
  • Loading branch information
sysprg committed Mar 19, 2021
1 parent 4e825b0 commit a74fa57
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 42 deletions.
73 changes: 73 additions & 0 deletions mysql-test/suite/galera/r/galera_log_bin_opt.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
connection node_1;
reset master;
connection node_2;
reset master;
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (id INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (1);
connection node_2;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
SELECT COUNT(*) = 2 FROM t2;
COUNT(*) = 2
1
connection node_1;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
mysqld-bin.000001 # Gtid # # GTID #-#-#
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
mysqld-bin.000001 # Table_map # # table_id: # (test.t1)
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Xid # # COMMIT /* XID */
mysqld-bin.000001 # Gtid # # GTID #-#-#
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Xid # # COMMIT /* XID */
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Xid # # COMMIT /* XID */
mysqld-bin.000001 # Gtid # # GTID #-#-#
mysqld-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
connection node_2;
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
COUNT(*) = 2
1
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
mysqld-bin.000001 # Gtid # # GTID #-#-#
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
mysqld-bin.000001 # Table_map # # table_id: # (test.t1)
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Xid # # COMMIT /* XID */
mysqld-bin.000001 # Gtid # # GTID #-#-#
mysqld-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Xid # # COMMIT /* XID */
mysqld-bin.000001 # Gtid # # BEGIN GTID #-#-#
mysqld-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
mysqld-bin.000001 # Table_map # # table_id: # (test.t2)
mysqld-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Xid # # COMMIT /* XID */
mysqld-bin.000001 # Gtid # # GTID #-#-#
mysqld-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
DROP TABLE t1;
DROP TABLE t2;
#cleanup
connection node_1;
RESET MASTER;
42 changes: 42 additions & 0 deletions mysql-test/suite/galera/t/galera_log_bin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--source include/galera_cluster.inc
--source include/force_restart.inc

--connection node_1
reset master;
--connection node_2
reset master;

#
# Test Galera with --log-bin --log-slave-updates .
# This way the actual MySQL binary log is used,
# rather than Galera's own implementation
#

CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);

CREATE TABLE t2 (id INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (1);

--connection node_2
SELECT COUNT(*) = 1 FROM t1;
SELECT COUNT(*) = 2 FROM t2;

--connection node_1
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
--let $MASTER_MYPORT=$NODE_MYPORT_1
--source include/show_binlog_events.inc

--connection node_2
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
--let $MASTER_MYPORT=$NODE_MYPORT_2
--source include/show_binlog_events.inc

DROP TABLE t1;
DROP TABLE t2;

--echo #cleanup
--connection node_1
RESET MASTER;

43 changes: 1 addition & 42 deletions mysql-test/suite/galera/t/galera_log_bin.test
Original file line number Diff line number Diff line change
@@ -1,42 +1 @@
--source include/galera_cluster.inc
--source include/force_restart.inc

--connection node_1
reset master;
--connection node_2
reset master;

#
# Test Galera with --log-bin --log-slave-updates .
# This way the actual MySQL binary log is used,
# rather than Galera's own implementation
#

CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);

CREATE TABLE t2 (id INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (1);

--connection node_2
SELECT COUNT(*) = 1 FROM t1;
SELECT COUNT(*) = 2 FROM t2;

--connection node_1
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
--let $MASTER_MYPORT=$NODE_MYPORT_1
--source include/show_binlog_events.inc

--connection node_2
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
--let $MASTER_MYPORT=$NODE_MYPORT_2
--source include/show_binlog_events.inc

DROP TABLE t1;
DROP TABLE t2;

--echo #cleanup
--connection node_1
RESET MASTER;

--source galera_log_bin.inc
1 change: 1 addition & 0 deletions mysql-test/suite/galera/t/galera_log_bin_opt-master.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--log-slave-updates --log-bin
15 changes: 15 additions & 0 deletions mysql-test/suite/galera/t/galera_log_bin_opt.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!include ../galera_2nodes.cnf

[mysqld]
wsrep_sst_method=mariabackup
wsrep_sst_auth="root:"

[mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true'

[mysqld.2]
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'

[sst]
transferfmt=@ENV.MTR_GALERA_TFMT
streamfmt=xbstream
2 changes: 2 additions & 0 deletions mysql-test/suite/galera/t/galera_log_bin_opt.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--source include/have_mariabackup.inc
--source galera_log_bin.inc
3 changes: 3 additions & 0 deletions scripts/wsrep_sst_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ case "$1" in
"$option" != "--port" && \
"$option" != "--socket" ]]; then
value=${1#*=}
if [ "$value" == "$1" ]; then
value=""
fi
case "$option" in
'--innodb-data-home-dir')
if [ -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
Expand Down

0 comments on commit a74fa57

Please sign in to comment.