Commit 1ea7d596 authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-26915: SST scripts do not take log_bin_index setting into account

Currently, SST scripts assume that the filename specified in
the --log-bin-index argument either does not contain an extension
or uses the standard ".index" extension. Similar assumptions are
used for the log_bin_index parameter read from the configuration
file. This commit adds support for arbitrary extensions for the
index file paths.
parent f21a36d5
connection node_2;
connection node_1;
connection node_1;
set global wsrep_on=OFF;
reset master;
set global wsrep_on=ON;
connection node_2;
set global wsrep_on=OFF;
reset master;
set global wsrep_on=ON;
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
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t1)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-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
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t1)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
DROP TABLE t1;
DROP TABLE t2;
#cleanup
connection node_1;
SET GLOBAL wsrep_on=OFF;
RESET MASTER;
!include ../galera_2nodes.cnf
[mysqld.1]
log-bin = hostname1-bin
log-bin-index = hostname1.bdx
log-slave-updates
[mysqld.2]
log-bin = hostname2-bin
log-bin-index = hostname2.bdx
log-slave-updates
......@@ -230,7 +230,7 @@ case "$1" in
shift
;;
'--binlog-index'|'--log-bin-index')
readonly WSREP_SST_OPT_BINLOG_INDEX="$2"
WSREP_SST_OPT_BINLOG_INDEX="$2"
shift
;;
'--log-basename')
......@@ -453,7 +453,7 @@ if [ -n "${MYSQLD_OPT_LOG_BIN:-}" -a \
fi
if [ -n "${MYSQLD_OPT_LOG_BIN_INDEX:-}" -a \
-z "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
readonly WSREP_SST_OPT_BINLOG_INDEX="$MYSQLD_OPT_LOG_BIN_INDEX"
WSREP_SST_OPT_BINLOG_INDEX="$MYSQLD_OPT_LOG_BIN_INDEX"
fi
if [ -n "${MYSQLD_OPT_DATADIR:-}" -a \
-z "$WSREP_SST_OPT_DATA" ]; then
......@@ -563,6 +563,16 @@ get_binlog()
# is already defined above):
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index"
fi
else
# Remove all directories from the index file path:
local filename="${WSREP_SST_OPT_BINLOG_INDEX##*/}"
# Check if the index file name contains the extension:
if [ "${filename%.*}" = "$filename" ]; then
# Let's add the default extension (".index"):
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG_INDEX.index"
else
readonly WSREP_SST_OPT_BINLOG_INDEX
fi
fi
fi
}
......
......@@ -1249,8 +1249,8 @@ then
cd "$binlog_dir"
wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
rm -fv "$WSREP_SST_OPT_BINLOG".[0-9]* 1>&2 \+ || true
binlog_index="${WSREP_SST_OPT_BINLOG_INDEX%.index}.index"
[ -f "$binlog_index" ] && rm -fv "$binlog_index" 1>&2 \+ || true
[ -f "$WSREP_SST_OPT_BINLOG_INDEX" ] && \
rm -fv "$WSREP_SST_OPT_BINLOG_INDEX" 1>&2 \+ || true
cd "$OLD_PWD"
fi
......@@ -1325,7 +1325,7 @@ then
cd "$BINLOG_DIRNAME"
for bfile in $(ls -1 "$BINLOG_FILENAME".[0-9]*); do
echo "$BINLOG_DIRNAME/$bfile" >> "${WSREP_SST_OPT_BINLOG_INDEX%.index}.index"
echo "$BINLOG_DIRNAME/$bfile" >> "$WSREP_SST_OPT_BINLOG_INDEX"
done
cd "$OLD_PWD"
......
......@@ -392,7 +392,7 @@ EOF
# Prepare binlog files
cd "$BINLOG_DIRNAME"
binlog_files_full=$(tail -n $BINLOG_N_FILES "${WSREP_SST_OPT_BINLOG_INDEX%.index}.index")
binlog_files_full=$(tail -n $BINLOG_N_FILES "$WSREP_SST_OPT_BINLOG_INDEX")
binlog_files=""
for ii in $binlog_files_full
......@@ -732,7 +732,7 @@ EOF
if [ -f "$BINLOG_TAR_FILE" ]; then
cd "$BINLOG_DIRNAME"
binlog_index="${WSREP_SST_OPT_BINLOG_INDEX%.index}.index"
binlog_index="$WSREP_SST_OPT_BINLOG_INDEX"
# Clean up old binlog files first
rm -f "$BINLOG_FILENAME".[0-9]*
......
This diff is collapsed.
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