mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-16676 Using malloc-lib=jemalloc in MariaDB 10.2 causes non-critical error about missing mysql_config on startup
- This commit is based on patch 84fe9720a4d2483ff67b6a and suggestion of Jean Weisbuch to use `ldconfig -p` - Format of ldconfig output: "libjemalloc.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libjemalloc.so.1" ``` $ ./scripts/mysqld_safe 201013 13:36:50 mysqld_safe Adding '/usr/lib/x86_64-linux-gnu/libjemalloc.so.1' to LD_PRELOAD for mysqld 201013 13:36:50 mysqld_safe Logging to '/home/anel/builds/data-10.5/mysqld_safe_anel.err'. 201013 13:36:50 mysqld_safe Starting mysqld daemon with databases from /home/anel/builds/data-10.5 ``` Reviewed by: Daniel Black, Faustin Lammler
This commit is contained in:
@ -456,25 +456,10 @@ mysqld_ld_preload_text() {
|
|||||||
echo "$text"
|
echo "$text"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mysql_config=
|
|
||||||
get_mysql_config() {
|
|
||||||
if [ -z "$mysql_config" ]; then
|
|
||||||
mysql_config=`echo "$0" | sed 's,/[^/][^/]*$,/mysql_config,'`
|
|
||||||
if [ ! -x "$mysql_config" ]; then
|
|
||||||
log_error "Can not run mysql_config $@ from '$mysql_config'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
"$mysql_config" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# set_malloc_lib LIB
|
# set_malloc_lib LIB
|
||||||
# - If LIB is empty, do nothing and return
|
# - If LIB is empty, do nothing and return
|
||||||
# - If LIB starts with 'tcmalloc' or 'jemalloc', look for the shared library in
|
# - If LIB starts with 'tcmalloc' or 'jemalloc', look for the shared library
|
||||||
# /usr/lib, /usr/lib64 and then pkglibdir.
|
# using `ldconfig`.
|
||||||
# tcmalloc is part of the Google perftools project.
|
# tcmalloc is part of the Google perftools project.
|
||||||
# - If LIB is an absolute path, assume it is a malloc shared library
|
# - If LIB is an absolute path, assume it is a malloc shared library
|
||||||
#
|
#
|
||||||
@ -482,28 +467,28 @@ get_mysql_config() {
|
|||||||
# running mysqld. See ld.so for details.
|
# running mysqld. See ld.so for details.
|
||||||
set_malloc_lib() {
|
set_malloc_lib() {
|
||||||
malloc_lib="$1"
|
malloc_lib="$1"
|
||||||
|
|
||||||
if expr "$malloc_lib" : "\(tcmalloc\|jemalloc\)" > /dev/null ; then
|
if expr "$malloc_lib" : "\(tcmalloc\|jemalloc\)" > /dev/null ; then
|
||||||
pkglibdir=`get_mysql_config --variable=pkglibdir`
|
if ! my_which ldconfig > /dev/null 2>&1
|
||||||
where=''
|
then
|
||||||
# This list is kept intentionally simple. Simply set --malloc-lib
|
log_error "ldconfig command not found, required for ldconfig -p"
|
||||||
# to a full path if another location is desired.
|
|
||||||
for libdir in /usr/lib /usr/lib64 "$pkglibdir" "$pkglibdir/mysql"; do
|
|
||||||
tmp=`echo "$libdir/lib$malloc_lib.so".[0-9]`
|
|
||||||
where="$where $libdir"
|
|
||||||
# log_notice "DEBUG: Checking for malloc lib '$tmp'"
|
|
||||||
[ -r "$tmp" ] || continue
|
|
||||||
malloc_lib="$tmp"
|
|
||||||
where=''
|
|
||||||
break
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$where" ]; then
|
|
||||||
log_error "no shared library for lib$malloc_lib.so.[0-9] found in$where"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
# format from ldconfig:
|
||||||
|
# "libjemalloc.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libjemalloc.so.1"
|
||||||
|
libmalloc_path="$(ldconfig -p | sed -n "/lib${malloc_lib}/p" | cut -d '>' -f2)"
|
||||||
|
|
||||||
|
if [ -z "$libmalloc_path" ]; then
|
||||||
|
log_error "no shared library for lib$malloc_lib.so.[0-9] found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for f in $libmalloc_path; do
|
||||||
|
if [ -f "$f" ]; then
|
||||||
|
malloc_lib=$f # get the first path if many
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
# Allow --malloc-lib='' to override other settings
|
# Allow --malloc-lib='' to override other settings
|
||||||
[ -z "$malloc_lib" ] && return
|
[ -z "$malloc_lib" ] && return
|
||||||
|
|
||||||
@ -520,7 +505,6 @@ set_malloc_lib() {
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
add_mysqld_ld_preload "$malloc_lib"
|
add_mysqld_ld_preload "$malloc_lib"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user