Commit 41fc2493 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5186 /usr/bin/mysqld_safe doesn't have NUMA options support

port mysqld_safe numa extensions from percona-server: --flush-caches and --numa-interleave
parent e10d42d9
...@@ -18,6 +18,8 @@ niceness=0 ...@@ -18,6 +18,8 @@ niceness=0
nowatch=0 nowatch=0
mysqld_ld_preload= mysqld_ld_preload=
mysqld_ld_library_path= mysqld_ld_library_path=
flush_caches=0
numa_interleave=0
# Initial logging status: error log is not open, and not using syslog # Initial logging status: error log is not open, and not using syslog
logging=init logging=init
...@@ -85,6 +87,10 @@ Usage: $0 [OPTIONS] ...@@ -85,6 +87,10 @@ Usage: $0 [OPTIONS]
--syslog Log messages to syslog with 'logger' --syslog Log messages to syslog with 'logger'
--skip-syslog Log messages to error log (default) --skip-syslog Log messages to error log (default)
--syslog-tag=TAG Pass -t "mysqld-TAG" to 'logger' --syslog-tag=TAG Pass -t "mysqld-TAG" to 'logger'
--flush-caches Flush and purge buffers/caches before
starting the server
--numa-interleave Run mysqld with its memory interleaved
on all NUMA nodes
All other options are passed to the mysqld program. All other options are passed to the mysqld program.
...@@ -244,6 +250,8 @@ parse_arguments() { ...@@ -244,6 +250,8 @@ parse_arguments() {
--skip-syslog) want_syslog=0 ;; --skip-syslog) want_syslog=0 ;;
--syslog-tag=*) syslog_tag="$val" ;; --syslog-tag=*) syslog_tag="$val" ;;
--timezone=*) TZ="$val"; export TZ; ;; --timezone=*) TZ="$val"; export TZ; ;;
--flush-caches) flush_caches=1 ;;
--numa-interleave) numa_interleave=1 ;;
--help) usage ;; --help) usage ;;
...@@ -761,6 +769,41 @@ mysqld daemon not started" ...@@ -761,6 +769,41 @@ mysqld daemon not started"
fi fi
fi fi
#
# Flush and purge buffers/caches.
#
if @TARGET_LINUX@ && test $flush_caches -eq 1
then
# Locate sync, ensure it exists.
if ! my_which sync > /dev/null 2>&1
then
log_error "sync command not found, required for --flush-caches"
exit 1
# Flush file system buffers.
elif ! sync
then
# Huh, the sync() function is always successful...
log_error "sync failed, check if sync is properly installed"
fi
# Locate sysctl, ensure it exists.
if ! my_which sysctl > /dev/null 2>&1
then
log_error "sysctl command not found, required for --flush-caches"
exit 1
# Purge page cache, dentries and inodes.
elif ! sysctl -q -w vm.drop_caches=3
then
log_error "sysctl failed, check the error message for details"
exit 1
fi
elif test $flush_caches -eq 1
then
log_error "--flush-caches is not supported on this platform"
exit 1
fi
# #
# Uncomment the following lines if you want all tables to be automatically # Uncomment the following lines if you want all tables to be automatically
# checked and repaired during startup. You should add sensible key_buffer # checked and repaired during startup. You should add sensible key_buffer
...@@ -781,6 +824,31 @@ fi ...@@ -781,6 +824,31 @@ fi
cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS" cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS"
#
# Set mysqld's memory interleave policy.
#
if @TARGET_LINUX@ && test $numa_interleave -eq 1
then
# Locate numactl, ensure it exists.
if ! my_which numactl > /dev/null 2>&1
then
log_error "numactl command not found, required for --numa-interleave"
exit 1
# Attempt to run a command, ensure it works.
elif ! numactl --interleave=all true
then
log_error "numactl failed, check if numactl is properly installed"
fi
# Launch mysqld with numactl.
cmd="$cmd numactl --interleave=all"
elif test $numa_interleave -eq 1
then
log_error "--numa-interleave is not supported on this platform"
exit 1
fi
for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \
"--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION" "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION"
do do
......
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