Skip to content

Commit fd9a11d

Browse files
committed
MDEV-35749: Add support for --use-memory option for SST with mariabackup
Mariabackup (mariadb-backup) supports the --use-memory option that sets the buffer pool size for innodb. However, current SST scripts do not use this option. This commit adds support for this option, the value for which can be specified via the "use_memory" parameter in the configuration file in the [sst], [mariabackup] or [xtrabackup] sections (supported only for compatibility with old configurations). In addition, if the innodb_buffer_pool_size option is specified in the user configuration (in the main server configuration sections) or passed to the SST scripts or the server via arguments, its value is also passed to mariadb-backup as the value for the --use-memory option. A new section name [mariabackup] has also been added, which can be used instead of the deprecated [xtrabackup] (the section name "mariabackup" was specified in the documentation, but was not actually supported by SST scripts before this commit).
1 parent 24e5d56 commit fd9a11d

File tree

5 files changed

+121
-17
lines changed

5 files changed

+121
-17
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
connection node_2;
2+
connection node_1;
3+
connection node_1;
4+
connection node_2;
5+
connection node_2;
6+
Shutting down server ...
7+
connection node_1;
8+
Cleaning var directory ...
9+
connection node_2;
10+
Starting server ...
11+
include/assert_grep.inc [mariabackup: Using 128974848 bytes for buffer pool \(set by --use-memory parameter\)]
12+
disconnect node_2;
13+
disconnect node_1;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
!include ../galera_2nodes.cnf
2+
3+
[mysqld]
4+
wsrep_sst_method=mariabackup
5+
wsrep_sst_auth="root:"
6+
7+
[mariabackup]
8+
use_memory=123m
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--source include/galera_cluster.inc
2+
--source include/have_innodb.inc
3+
--source include/have_mariabackup.inc
4+
5+
# Save original auto_increment_offset values.
6+
--let $node_1=node_1
7+
--let $node_2=node_2
8+
--source include/auto_increment_offset_save.inc
9+
10+
--connection node_2
11+
12+
--echo Shutting down server ...
13+
--source include/shutdown_mysqld.inc
14+
15+
--connection node_1
16+
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
17+
--source include/wait_condition.inc
18+
19+
#
20+
# Force SST
21+
#
22+
--echo Cleaning var directory ...
23+
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
24+
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/mtr
25+
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/performance_schema
26+
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/test
27+
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/mysql
28+
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data
29+
30+
--connection node_2
31+
32+
--echo Starting server ...
33+
let $restart_noprint=2;
34+
--source include/start_mysqld.inc
35+
36+
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
37+
--source include/wait_condition.inc
38+
39+
--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
40+
--source include/wait_condition.inc
41+
42+
# Confirm that IST did not take place
43+
--let $assert_text = mariabackup: Using 128974848 bytes for buffer pool \(set by --use-memory parameter\)
44+
--let $assert_select = mariabackup: Using 128974848 bytes for buffer pool \(set by --use-memory parameter\)
45+
--let $assert_count = 1
46+
--let $assert_file = $MYSQLTEST_VARDIR/mysqld.2/data/mariabackup.prepare.log
47+
--let $assert_only_after = Starting InnoDB instance for recovery
48+
--source include/assert_grep.inc
49+
50+
# Restore original auto_increment_offset values.
51+
--source include/auto_increment_offset_restore.inc
52+
53+
--source include/galera_end.inc

scripts/wsrep_sst_common.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ INNODB_DATA_HOME_DIR=$(trim_dir "${INNODB_DATA_HOME_DIR:-}")
209209
INNODB_LOG_GROUP_HOME=$(trim_dir "${INNODB_LOG_GROUP_HOME:-}")
210210
INNODB_UNDO_DIR=$(trim_dir "${INNODB_UNDO_DIR:-}")
211211
INNODB_BUFFER_POOL=""
212+
INNODB_BUFFER_POOL_SIZE=""
212213
INNODB_FORCE_RECOVERY=""
213214
INNOEXTRA=""
214215

@@ -329,6 +330,10 @@ case "$1" in
329330
readonly INNODB_BUFFER_POOL=$(trim_string "$2")
330331
shift
331332
;;
333+
'--innodb-buffer-pool-size')
334+
readonly INNODB_BUFFER_POOL_SIZE=$(trim_string "$2")
335+
shift
336+
;;
332337
'--defaults-file')
333338
file=$(trim_string "$2")
334339
readonly WSREP_SST_OPT_DEFAULT="$1=$file"
@@ -607,6 +612,12 @@ case "$1" in
607612
fi
608613
skip_mysqld_arg=1
609614
;;
615+
'--innodb-buffer-pool-size')
616+
if [ -z "$INNODB_BUFFER_POOL_SIZE" ]; then
617+
MYSQLD_OPT_INNODB_BUFFER_POOL_SIZE=$(trim_string "$value")
618+
fi
619+
skip_mysqld_arg=1
620+
;;
610621
'--innodb-force-recovery')
611622
if [ -n "$value" -a "$value" != "0" ]; then
612623
INNODB_FORCE_RECOVERY=$(trim_string "$value")
@@ -696,6 +707,10 @@ if [ -n "${MYSQLD_OPT_INNODB_BUFFER_POOL:-}" -a \
696707
-z "$INNODB_BUFFER_POOL" ]; then
697708
readonly INNODB_BUFFER_POOL="$MYSQLD_OPT_INNODB_BUFFER_POOL"
698709
fi
710+
if [ -n "${MYSQLD_OPT_INNODB_BUFFER_POOL_SIZE:-}" -a \
711+
-z "$INNODB_BUFFER_POOL_SIZE" ]; then
712+
readonly INNODB_BUFFER_POOL_SIZE="$MYSQLD_OPT_INNODB_BUFFER_POOL_SIZE"
713+
fi
699714
if [ -n "${MYSQLD_OPT_LOG_BIN:-}" -a \
700715
-z "$WSREP_SST_OPT_BINLOG" ]; then
701716
readonly WSREP_SST_OPT_BINLOG="$MYSQLD_OPT_LOG_BIN"
@@ -752,6 +767,9 @@ fi
752767
if [ -n "$INNODB_BUFFER_POOL" ]; then
753768
INNOEXTRA="$INNOEXTRA --innodb-buffer-pool-filename='$INNODB_BUFFER_POOL'"
754769
fi
770+
if [ -n "$INNODB_BUFFER_POOL_SIZE" ]; then
771+
INNOEXTRA="$INNOEXTRA --innodb-buffer-pool-size='$INNODB_BUFFER_POOL_SIZE'"
772+
fi
755773
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
756774
INNOEXTRA="$INNOEXTRA --log-bin='$WSREP_SST_OPT_BINLOG'"
757775
if [ -n "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
@@ -1775,14 +1793,14 @@ simple_cleanup()
17751793
create_data()
17761794
{
17771795
OLD_PWD="$(pwd)"
1796+
DATA_DIR="$OLD_PWD"
17781797

17791798
if [ -n "$DATA" -a "$DATA" != '.' ]; then
17801799
[ ! -d "$DATA" ] && mkdir -p "$DATA"
17811800
cd "$DATA"
1801+
DATA_DIR="$(pwd)"
1802+
cd "$OLD_PWD"
17821803
fi
1783-
DATA_DIR="$(pwd)"
1784-
1785-
cd "$OLD_PWD"
17861804
}
17871805

17881806
create_dirs()

scripts/wsrep_sst_mariabackup.sh

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ adjust_progress()
540540
fi
541541
}
542542

543-
encgroups='--mysqld|sst|xtrabackup'
543+
bkgroups='sst|xtrabackup|mariabackup'
544+
encgroups="--mysqld|$bkgroups"
544545

545546
read_cnf()
546547
{
@@ -596,26 +597,34 @@ read_cnf()
596597
ssl_dhparams=$(parse_cnf "$encgroups" 'ssl-dhparams')
597598
fi
598599

599-
sockopt=$(parse_cnf sst sockopt "")
600-
progress=$(parse_cnf sst progress "")
600+
sockopt=$(parse_cnf sst sockopt)
601+
progress=$(parse_cnf sst progress)
601602
ttime=$(parse_cnf sst time 0)
602603
cpat='.*\.pem$\|.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$'
603604
[ "$OS" = 'FreeBSD' ] && cpat=$(echo "$cpat" | sed 's/\\|/|/g')
604605
cpat=$(parse_cnf sst cpat "$cpat")
605-
scomp=$(parse_cnf sst compressor "")
606-
sdecomp=$(parse_cnf sst decompressor "")
606+
scomp=$(parse_cnf sst compressor)
607+
sdecomp=$(parse_cnf sst decompressor)
607608

608-
rlimit=$(parse_cnf sst rlimit "")
609+
rlimit=$(parse_cnf sst rlimit)
609610
uextra=$(parse_cnf sst use-extra 0)
610-
speciald=$(parse_cnf sst sst-special-dirs 1)
611-
iopts=$(parse_cnf sst inno-backup-opts "")
612-
iapts=$(parse_cnf sst inno-apply-opts "")
613-
impts=$(parse_cnf sst inno-move-opts "")
614-
stimeout=$(parse_cnf sst sst-initial-timeout 300)
615-
ssyslog=$(parse_cnf sst sst-syslog 0)
616-
ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
611+
speciald=$(parse_cnf sst 'sst-special-dirs' 1)
612+
iopts=$(parse_cnf "$bkgroups" 'inno-backup-opts')
613+
iapts=$(parse_cnf "$bkgroups" 'inno-apply-opts')
614+
impts=$(parse_cnf "$bkgroups" 'inno-move-opts')
615+
use_memory=$(parse_cnf "$bkgroups" 'use-memory')
616+
if [ -z "$use_memory" ]; then
617+
if [ -n "$INNODB_BUFFER_POOL_SIZE" ]; then
618+
use_memory="$INNODB_BUFFER_POOL_SIZE"
619+
else
620+
use_memory=$(parse_cnf '--mysqld' 'innodb-buffer-pool-size')
621+
fi
622+
fi
623+
stimeout=$(parse_cnf sst 'sst-initial-timeout' 300)
624+
ssyslog=$(parse_cnf sst 'sst-syslog' 0)
625+
ssystag=$(parse_cnf mysqld_safe 'syslog-tag' "${SST_SYSLOG_TAG:-}")
617626
ssystag="$ssystag-"
618-
sstlogarchive=$(parse_cnf sst sst-log-archive 1)
627+
sstlogarchive=$(parse_cnf sst 'sst-log-archive' 1)
619628
sstlogarchivedir=""
620629
if [ $sstlogarchive -ne 0 ]; then
621630
sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir \
@@ -1053,6 +1062,9 @@ setup_commands()
10531062
if [ -n "$INNODB_FORCE_RECOVERY" ]; then
10541063
recovery=" --innodb-force-recovery=$INNODB_FORCE_RECOVERY"
10551064
fi
1065+
if [ -n "$use_memory" ]; then
1066+
INNOEXTRA="$INNOEXTRA --use-memory=$use_memory"
1067+
fi
10561068
INNOAPPLY="$BACKUP_BIN --prepare$disver$recovery${iapts:+ }$iapts$INNOEXTRA --target-dir='$DATA' --datadir='$DATA'$mysqld_args $INNOAPPLY"
10571069
INNOMOVE="$BACKUP_BIN$WSREP_SST_OPT_CONF --move-back$disver${impts:+ }$impts$INNOEXTRA --galera-info --force-non-empty-directories --target-dir='$DATA' --datadir='${TDATA:-$DATA}' $INNOMOVE"
10581070
INNOBACKUP="$BACKUP_BIN$WSREP_SST_OPT_CONF --backup$disver${iopts:+ }$iopts$tmpopts$INNOEXTRA --galera-info --stream=$sfmt --target-dir='$itmpdir' --datadir='$DATA'$mysqld_args $INNOBACKUP"

0 commit comments

Comments
 (0)