Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
grooverdan committed Aug 8, 2024
2 parents 3b1dd06 + 64decf7 commit b45425d
Show file tree
Hide file tree
Showing 57 changed files with 4,333 additions and 276 deletions.
4 changes: 2 additions & 2 deletions .test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ if [ -n "$debarch" ]
then
echo -e "Test: jemalloc preload\n"
runandwait -e LD_PRELOAD="/usr/lib/$debarch-linux-gnu/libjemalloc.so.1 /usr/lib/$debarch-linux-gnu/libjemalloc.so.2 /usr/lib64/libjemalloc.so.2" -e MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 "${image}"
docker exec -i "$cid" gosu mysql /bin/grep 'jemalloc' /proc/1/maps || die "expected to preload jemalloc"
docker exec -i --user mysql "$cid" /bin/grep 'jemalloc' /proc/1/maps || die "expected to preload jemalloc"


killoff
Expand Down Expand Up @@ -765,7 +765,7 @@ fi
--network=container:"$master_host" \
--health-cmd='healthcheck.sh --replication_io --replication_sql --replication_seconds_behind_master=0 --replication' \
--health-interval=3s \
"$image" --server-id=2 --port 3307)
"$image" --server-id=2 --port 3307 --require-secure-transport=1)

c="${DOCKER_LIBRARY_START_TIMEOUT:-10}"
until docker exec "$cid" healthcheck.sh --connect --replication_io --replication_sql --replication_seconds_behind_master=0 --replication || [ "$c" -eq 0 ]
Expand Down
6 changes: 4 additions & 2 deletions 10.11-ubi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ LABEL org.opencontainers.image.authors="MariaDB Community" \

# bashbrew-architectures: amd64 arm64v8 ppc64le s390x
ARG MARIADB_VERSION=10.11.8
ENV MARIADB_VERSION=$MARIADB_VERSION
# release-status:Stable
# release-support-type:Long Term Support
# (https://downloads.mariadb.org/rest-api/mariadb/)
Expand Down Expand Up @@ -85,7 +86,7 @@ RUN set -eux ; \
microdnf install -y procps-ng zstd xz jemalloc pwgen pv ; \
mkdir -p /etc/mysql/conf.d /etc/mysql/mariadb.conf.d/ /var/lib/mysql/mysql /run/mariadb /usr/lib64/galera ; \
chmod ugo+rwx,o+t /run/mariadb ; \
microdnf install -y MariaDB-backup-10.11.8 MariaDB-server-10.11.8 ; \
microdnf install -y MariaDB-backup-${MARIADB_VERSION} MariaDB-server-${MARIADB_VERSION} ; \
# compatibility with DEB Galera packaging
ln -s /usr/lib64/galera-4/libgalera_smm.so /usr/lib/libgalera_smm.so ; \
# compatibility with RPM Galera packaging
Expand All @@ -94,7 +95,7 @@ RUN set -eux ; \
rmdir /var/lib/mysql/mysql ; \
chown -R mysql:mysql /var/lib/mysql /run/mariadb ; \
mkdir /licenses ; \
ln -s /usr/share/doc/MariaDB-server-10.11.8/COPYING /licenses/GPL-2 ; \
ln -s /usr/share/doc/MariaDB-server-${MARIADB_VERSION}/COPYING /licenses/GPL-2 ; \
ln -s /usr/share/licenses /licenses/package-licenses ; \
ln -s Apache-2.0-license /licenses/gosu

Expand All @@ -107,5 +108,6 @@ COPY docker-entrypoint.sh /usr/local/bin/

ENTRYPOINT ["docker-entrypoint.sh"]

USER mysql
EXPOSE 3306
CMD ["mariadbd"]
10 changes: 6 additions & 4 deletions 10.11-ubi/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ docker_create_db_directories() {

if [ "$user" = "0" ]; then
# this will cause less disk access than `chown -R`
find "$DATADIR" \! -user mysql -exec chown mysql: '{}' +
find "$DATADIR" \! -user mysql \( -exec chown mysql: '{}' + -o -true \)
# See https://github.com/MariaDB/mariadb-docker/issues/363
find "${SOCKET%/*}" -maxdepth 0 \! -user mysql -exec chown mysql: '{}' \;
if [ "${SOCKET:0:1}" != '@' ]; then # not abstract sockets
find "${SOCKET%/*}" -maxdepth 0 \! -user mysql \( -exec chown mysql: '{}' \; -o -true \)
fi

# memory.pressure
local cgroup; cgroup=$(</proc/self/cgroup)
Expand Down Expand Up @@ -353,7 +355,7 @@ create_healthcheck_users() {
local maskPreserve
maskPreserve=$(umask -p)
umask 0077
echo -e "[mariadb-client]\\nport=$PORT\\nsocket=$SOCKET\\nuser=healthcheck\\npassword=$healthCheckConnectPass\\nprotocol=tcp\\n" > "$DATADIR"/.my-healthcheck.cnf
echo -e "[mariadb-client]\\nport=$PORT\\nsocket=$SOCKET\\nuser=healthcheck\\npassword=$healthCheckConnectPass\\n" > "$DATADIR"/.my-healthcheck.cnf
$maskPreserve
}

Expand Down Expand Up @@ -526,7 +528,7 @@ docker_mariadb_init()
rm -rf "$DATADIR"/.init "$DATADIR"/.restore
if [ "$(id -u)" = "0" ]; then
# this will cause less disk access than `chown -R`
find "$DATADIR" \! -user mysql -exec chown mysql: '{}' +
find "$DATADIR" \! -user mysql \( -exec chown mysql: '{}' + -o -true \)
fi
done
if _check_if_upgrade_is_needed; then
Expand Down
30 changes: 25 additions & 5 deletions 10.11-ubi/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# the --replication option. This allows a different set of replication checks
# on different connections.
#
# --su{=|-mariadb} is option to run the healthcheck as a different unix user.
# Useful if mariadb@localhost user exists with unix socket authentication
# --su{=|-mysql} is option to run the healthcheck as a different unix user.
# Useful if mysql@localhost user exists with unix socket authentication
# Using this option disregards previous options set, so should usually be the
# first option.
#
Expand All @@ -32,7 +32,7 @@
# different from elsewhere.
#
# Note * though denied error message will result in error log without
# any permissions.
# any permissions. USAGE recommend to avoid this.

set -eo pipefail

Expand All @@ -42,6 +42,7 @@ _process_sql()
${def['file']:+--defaults-file=${def['file']}} \
${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \
${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \
--protocol socket \
-B "$@"
}

Expand All @@ -55,6 +56,16 @@ _process_sql()
# isn't tested.
connect()
{
local s
# short cut mechanism, to work with --require-secure-transport
s=$(_process_sql --skip-column-names -e 'select @@skip_networking')
case "$s" in
0|1)
connect_s=$s
return "$s";
;;
esac
# falling back to this if there wasn't a connection answer.
set +e +o pipefail
# (on second extra_file)
# shellcheck disable=SC2086
Expand All @@ -68,9 +79,11 @@ connect()
set -eo pipefail
if (( "$ret" == 0 )); then
# grep Matched "Can't connect" so we fail
return 1
connect_s=1
else
connect_s=0
fi
return 0
return $connect_s
}

# INNODB_INITIALIZED
Expand Down Expand Up @@ -225,6 +238,7 @@ fi
declare -A repl
declare -A def
nodefaults=
connect_s=
datadir=/var/lib/mysql
if [ -f $datadir/.my-healthcheck.cnf ]; then
def['extra_file']=$datadir/.my-healthcheck.cnf
Expand Down Expand Up @@ -351,3 +365,9 @@ while [ $# -gt 0 ]; do
fi
shift
done
if [ -z "$connect_s" ]; then
# we didn't do a connnect test, so the current success status is suspicious
# return what connect thinks.
connect
exit $?
fi
10 changes: 6 additions & 4 deletions 10.11/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ docker_create_db_directories() {

if [ "$user" = "0" ]; then
# this will cause less disk access than `chown -R`
find "$DATADIR" \! -user mysql -exec chown mysql: '{}' +
find "$DATADIR" \! -user mysql \( -exec chown mysql: '{}' + -o -true \)
# See https://github.com/MariaDB/mariadb-docker/issues/363
find "${SOCKET%/*}" -maxdepth 0 \! -user mysql -exec chown mysql: '{}' \;
if [ "${SOCKET:0:1}" != '@' ]; then # not abstract sockets
find "${SOCKET%/*}" -maxdepth 0 \! -user mysql \( -exec chown mysql: '{}' \; -o -true \)
fi

# memory.pressure
local cgroup; cgroup=$(</proc/self/cgroup)
Expand Down Expand Up @@ -353,7 +355,7 @@ create_healthcheck_users() {
local maskPreserve
maskPreserve=$(umask -p)
umask 0077
echo -e "[mariadb-client]\\nport=$PORT\\nsocket=$SOCKET\\nuser=healthcheck\\npassword=$healthCheckConnectPass\\nprotocol=tcp\\n" > "$DATADIR"/.my-healthcheck.cnf
echo -e "[mariadb-client]\\nport=$PORT\\nsocket=$SOCKET\\nuser=healthcheck\\npassword=$healthCheckConnectPass\\n" > "$DATADIR"/.my-healthcheck.cnf
$maskPreserve
}

Expand Down Expand Up @@ -526,7 +528,7 @@ docker_mariadb_init()
rm -rf "$DATADIR"/.init "$DATADIR"/.restore
if [ "$(id -u)" = "0" ]; then
# this will cause less disk access than `chown -R`
find "$DATADIR" \! -user mysql -exec chown mysql: '{}' +
find "$DATADIR" \! -user mysql \( -exec chown mysql: '{}' + -o -true \)
fi
done
if _check_if_upgrade_is_needed; then
Expand Down
30 changes: 25 additions & 5 deletions 10.11/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# the --replication option. This allows a different set of replication checks
# on different connections.
#
# --su{=|-mariadb} is option to run the healthcheck as a different unix user.
# Useful if mariadb@localhost user exists with unix socket authentication
# --su{=|-mysql} is option to run the healthcheck as a different unix user.
# Useful if mysql@localhost user exists with unix socket authentication
# Using this option disregards previous options set, so should usually be the
# first option.
#
Expand All @@ -32,7 +32,7 @@
# different from elsewhere.
#
# Note * though denied error message will result in error log without
# any permissions.
# any permissions. USAGE recommend to avoid this.

set -eo pipefail

Expand All @@ -42,6 +42,7 @@ _process_sql()
${def['file']:+--defaults-file=${def['file']}} \
${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \
${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \
--protocol socket \
-B "$@"
}

Expand All @@ -55,6 +56,16 @@ _process_sql()
# isn't tested.
connect()
{
local s
# short cut mechanism, to work with --require-secure-transport
s=$(_process_sql --skip-column-names -e 'select @@skip_networking')
case "$s" in
0|1)
connect_s=$s
return "$s";
;;
esac
# falling back to this if there wasn't a connection answer.
set +e +o pipefail
# (on second extra_file)
# shellcheck disable=SC2086
Expand All @@ -68,9 +79,11 @@ connect()
set -eo pipefail
if (( "$ret" == 0 )); then
# grep Matched "Can't connect" so we fail
return 1
connect_s=1
else
connect_s=0
fi
return 0
return $connect_s
}

# INNODB_INITIALIZED
Expand Down Expand Up @@ -225,6 +238,7 @@ fi
declare -A repl
declare -A def
nodefaults=
connect_s=
datadir=/var/lib/mysql
if [ -f $datadir/.my-healthcheck.cnf ]; then
def['extra_file']=$datadir/.my-healthcheck.cnf
Expand Down Expand Up @@ -351,3 +365,9 @@ while [ $# -gt 0 ]; do
fi
shift
done
if [ -z "$connect_s" ]; then
# we didn't do a connnect test, so the current success status is suspicious
# return what connect thinks.
connect
exit $?
fi
18 changes: 10 additions & 8 deletions 10.5/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ docker_create_db_directories() {

if [ "$user" = "0" ]; then
# this will cause less disk access than `chown -R`
find "$DATADIR" \! -user mysql -exec chown mysql: '{}' +
find "$DATADIR" \! -user mysql \( -exec chown mysql: '{}' + -o -true \)
# See https://github.com/MariaDB/mariadb-docker/issues/363
find "${SOCKET%/*}" -maxdepth 0 \! -user mysql -exec chown mysql: '{}' \;
if [ "${SOCKET:0:1}" != '@' ]; then # not abstract sockets
find "${SOCKET%/*}" -maxdepth 0 \! -user mysql \( -exec chown mysql: '{}' \; -o -true \)
fi

fi
}
Expand All @@ -221,16 +223,16 @@ docker_init_database_dir() {
installArgs=( --datadir="$DATADIR" --rpm --auth-root-authentication-method=normal )
# "Other options are passed to mysqld." (so we pass all "mysqld" arguments directly here)

local mariadbdArgs=()
local mysqldArgs=()
for arg in "${@:2}"; do
# Check if the argument contains whitespace
if [[ "$arg" =~ [[:space:]] ]]; then
mysql_warn "Not passing argument \'$arg\' to mariadb-install-db because mariadb-install-db does not support arguments with whitespace."
mysql_warn "Not passing argument \'$arg\' to mysql_install_db because mysql_install_db does not support arguments with whitespace."
else
mariadbdArgs+=("$arg")
mysqldArgs+=("$arg")
fi
done
mysql_install_db "${installArgs[@]}" "${mariadbdArgs[@]}" \
mysql_install_db "${installArgs[@]}" "${mysqldArgs[@]}" \
--skip-test-db \
--default-time-zone=SYSTEM --enforce-storage-engine= \
--skip-log-bin \
Expand Down Expand Up @@ -344,7 +346,7 @@ create_healthcheck_users() {
local maskPreserve
maskPreserve=$(umask -p)
umask 0077
echo -e "[mariadb-client]\\nport=$PORT\\nsocket=$SOCKET\\nuser=healthcheck\\npassword=$healthCheckConnectPass\\nprotocol=tcp\\n" > "$DATADIR"/.my-healthcheck.cnf
echo -e "[mariadb-client]\\nport=$PORT\\nsocket=$SOCKET\\nuser=healthcheck\\npassword=$healthCheckConnectPass\\n" > "$DATADIR"/.my-healthcheck.cnf
$maskPreserve
}

Expand Down Expand Up @@ -517,7 +519,7 @@ docker_mariadb_init()
rm -rf "$DATADIR"/.init "$DATADIR"/.restore
if [ "$(id -u)" = "0" ]; then
# this will cause less disk access than `chown -R`
find "$DATADIR" \! -user mysql -exec chown mysql: '{}' +
find "$DATADIR" \! -user mysql \( -exec chown mysql: '{}' + -o -true \)
fi
done
if _check_if_upgrade_is_needed; then
Expand Down
28 changes: 24 additions & 4 deletions 10.5/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
# replication REPLICATION_CLIENT (<10.5)or REPLICA MONITOR (10.5+)
# mariadbupgrade none, however unix user permissions on datadir
#
# The SQL user used is the default for the mysql client. This can be the unix user
# The SQL user used is the default for the mariadb client. This can be the unix user
# if no user(or password) is set in the [mariadb-client] section of a configuration
# file. --defaults-{file,extra-file,group-suffix} can specify a file/configuration
# different from elsewhere.
#
# Note * though denied error message will result in error log without
# any permissions.
# any permissions. USAGE recommend to avoid this.

set -eo pipefail

Expand All @@ -42,6 +42,7 @@ _process_sql()
${def['file']:+--defaults-file=${def['file']}} \
${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \
${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \
--protocol socket \
-B "$@"
}

Expand All @@ -55,6 +56,16 @@ _process_sql()
# isn't tested.
connect()
{
local s
# short cut mechanism, to work with --require-secure-transport
s=$(_process_sql --skip-column-names -e 'select @@skip_networking')
case "$s" in
0|1)
connect_s=$s
return "$s";
;;
esac
# falling back to this if there wasn't a connection answer.
set +e +o pipefail
# (on second extra_file)
# shellcheck disable=SC2086
Expand All @@ -68,9 +79,11 @@ connect()
set -eo pipefail
if (( "$ret" == 0 )); then
# grep Matched "Can't connect" so we fail
return 1
connect_s=1
else
connect_s=0
fi
return 0
return $connect_s
}

# INNODB_INITIALIZED
Expand Down Expand Up @@ -225,6 +238,7 @@ fi
declare -A repl
declare -A def
nodefaults=
connect_s=
datadir=/var/lib/mysql
if [ -f $datadir/.my-healthcheck.cnf ]; then
def['extra_file']=$datadir/.my-healthcheck.cnf
Expand Down Expand Up @@ -351,3 +365,9 @@ while [ $# -gt 0 ]; do
fi
shift
done
if [ -z "$connect_s" ]; then
# we didn't do a connnect test, so the current success status is suspicious
# return what connect thinks.
connect
exit $?
fi
Loading

0 comments on commit b45425d

Please sign in to comment.