Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RONDB-205: Add options --mysqld-instrumentation and --extra-packages #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ARG TARGETPLATFORM
ARG TARGETARCH
ARG TARGETVARIANT

ARG EXTRA_PACKAGES

ARG OPEN_SSL_VERSION=1.1.1s

RUN echo "Running on $BUILDPLATFORM, building for $TARGETPLATFORM"
Expand All @@ -22,6 +24,7 @@ RUN --mount=type=cache,target=/var/cache/apt,id=ubuntu22-apt \
--mount=type=cache,target=/var/lib/apt/lists,id=ubuntu22-apt-lists \
apt-get update -y \
&& apt-get install -y wget tar gzip \
$EXTRA_PACKAGES \
libncurses5 libnuma-dev \
bc
# bc is required by dbt2
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ It may be the case that the benchmarks require more resources than are configure

***Note***: Benchmarking RonDB with a docker-compose setup on a single machine may not bring optimal performance results. This is because both the mysqlds and the ndbmtds (multi-threaded data nodes) scale in performance with more CPUs. In a production setting, each of these programs would be deployed on their own VM, whereby mysqlds and ndbmtds will scale linearly with up to 32 cores. The possibility of benchmarking was added here to give the user an introduction of benchmarking RonDB without needing to spin up a cluster with VMs.

## Instrumentation for mysqld

Instrumenting `mysqld` is recommended only for advanced debugging scenarios.
The `--mysqld-instrumentation` argument is used to prepend the command line that starts `mysqld`.
Use the `--extra-packages` argument to list the packages you need installed for this purpose.
Example:

```bash
# Use valgrind to check for memory leaks during a benchmark run. Since we use the
# --volumes-in-local-dir flag, the memcheck output will be saved under
# `autogenerated_files/*/volumes/mysqlFilesDir_mysqld_*/`.
./build_run_docker.sh \
--rondb-tarball-is-local \
-ruri ./rondb-21.04.9-linux-glibc2.35-arm64_v8.tar.gz \
-v 21.04.9 -m 1 -g 1 -r 2 -my 1 -a 1 \
--mysqld-instrumentation "valgrind --log-file=/srv/hops/mysql-cluster/mysql-files/memcheck.log" \
--extra-packages valgrind \
--volumes-in-local-dir \
--run-benchmark sysbench_single
```

## Goals of this repository

1. Create an image with RonDB installed "hopsworks/rondb-standalone:21.04.9"
Expand Down
70 changes: 54 additions & 16 deletions build_run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Usage: $0
]
[-rtarl --rondb-tarball-is-local ]
[-lv --volumes-in-local-dir ]
[-mi --mysqld-instrumentation ]
[-ep --extra-packages ]
EOF
}

Expand All @@ -62,6 +64,8 @@ REPLICATION_FACTOR=1
NODE_GROUPS=1
RUN_BENCHMARK=
VOLUME_TYPE=docker
MYSQLD_INSTRUMENTATION=
EXTRA_PACKAGES=

POSITIONAL=()
while [[ $# -gt 0 ]]; do
Expand Down Expand Up @@ -124,28 +128,45 @@ while [[ $# -gt 0 ]]; do
shift # past argument
;;

-mi | --mysqld-instrumentation)
MYSQLD_INSTRUMENTATION="$2"
shift # past argument
shift # past value
;;

-ep | --extra-packages)
EXTRA_PACKAGES="$2"
shift # past argument
shift # past value
;;

*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done

echo "#################"
echo "Parsed arguments:"
echo "#################"
echo
echo "RonDB version = ${RONDB_VERSION}"
echo "RonDB tarball local/remote = ${RONDB_TARBALL_LOCAL_REMOTE}"
echo "RonDB tarball URI = ${RONDB_TARBALL_URI}"
echo "Number of management nodes = ${NUM_MGM_NODES}"
echo "Node groups = ${NODE_GROUPS}"
echo "Replication factor = ${REPLICATION_FACTOR}"
echo "Number of mysql nodes = ${NUM_MYSQL_NODES}"
echo "Number of api nodes = ${NUM_API_NODES}"
echo "Run benchmark = ${RUN_BENCHMARK}"
echo "Volume type docker/local = ${VOLUME_TYPE}"
echo
print-parsed-arguments(){
echo "#################"
echo "Parsed arguments:"
echo "#################"
echo
echo "RonDB version = ${RONDB_VERSION}"
echo "RonDB tarball local/remote = ${RONDB_TARBALL_LOCAL_REMOTE}"
echo "RonDB tarball URI = ${RONDB_TARBALL_URI}"
echo "Number of management nodes = ${NUM_MGM_NODES}"
echo "Node groups = ${NODE_GROUPS}"
echo "Replication factor = ${REPLICATION_FACTOR}"
echo "Number of mysql nodes = ${NUM_MYSQL_NODES}"
echo "Number of api nodes = ${NUM_API_NODES}"
echo "Run benchmark = ${RUN_BENCHMARK}"
echo "Volume type docker/local = ${VOLUME_TYPE}"
echo "Instrumentation mysqld = ${MYSQLD_INSTRUMENTATION}"
echo "Extra packages = ${EXTRA_PACKAGES}"
echo
}
print-parsed-arguments

set -- "${POSITIONAL[@]}" # restore unknown options
if [[ -n $1 ]]; then
Expand Down Expand Up @@ -219,17 +240,29 @@ fi

# We use this for the docker-compose project name, which will not allow "."
RONDB_VERSION_NO_DOT=$(echo "$RONDB_VERSION" | tr -d '.')
# We can't put an arbitrary command line or arbitrary list of packages as part
# of a filename, so hash them. User can refer to parsed_arguments.txt for full
# context.
MYSQLD_INSTRUMENTATION_INDICATOR=
if [ -n "$MYSQLD_INSTRUMENTATION" ]; then
MYSQLD_INSTRUMENTATION_INDICATOR="$(echo "$MYSQLD_INSTRUMENTATION" | sha256sum | sed -r 's/^(.{8}).*$/_mi-\1/')"
fi
EXTRA_PACKAGES_INDICATOR=
if [ -n "$EXTRA_PACKAGES" ]; then
EXTRA_PACKAGES_INDICATOR="$(echo "$EXTRA_PACKAGES" | sha256sum | sed -r 's/^(.{8}).*$/_ep-\1/')"
fi

## Uncomment this for quicker testing
# yes | docker container prune
# yes | docker volume prune

FILE_SUFFIX="v${RONDB_VERSION_NO_DOT}_m${NUM_MGM_NODES}_g${NODE_GROUPS}_r${REPLICATION_FACTOR}_my${NUM_MYSQL_NODES}_api${NUM_API_NODES}"
FILE_SUFFIX="v${RONDB_VERSION_NO_DOT}_m${NUM_MGM_NODES}_g${NODE_GROUPS}_r${REPLICATION_FACTOR}_my${NUM_MYSQL_NODES}_api${NUM_API_NODES}${MYSQLD_INSTRUMENTATION_INDICATOR}${EXTRA_PACKAGES_INDICATOR}"

# https://stackoverflow.com/a/246128/9068781
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
AUTOGENERATED_FILES_DIR="$SCRIPT_DIR/autogenerated_files/$FILE_SUFFIX"
mkdir -p $AUTOGENERATED_FILES_DIR
print-parsed-arguments > "$AUTOGENERATED_FILES_DIR/parsed_arguments.txt"

DOCKER_COMPOSE_FILEPATH="$AUTOGENERATED_FILES_DIR/docker_compose.yml"
CONFIG_INI_FILEPATH="$AUTOGENERATED_FILES_DIR/config.ini"
Expand Down Expand Up @@ -273,6 +306,7 @@ docker buildx build . \
--tag $RONDB_IMAGE_NAME \
--build-arg RONDB_VERSION=$RONDB_VERSION \
--build-arg RONDB_TARBALL_LOCAL_REMOTE=$RONDB_TARBALL_LOCAL_REMOTE \
--build-arg "EXTRA_PACKAGES=$EXTRA_PACKAGES" \
--build-arg RONDB_TARBALL_URI=$RONDB_TARBALL_URI

#######################
Expand Down Expand Up @@ -534,6 +568,10 @@ if [ $NUM_MYSQL_NODES -gt 0 ]; then
env_var=$(printf "$ENV_VAR_TEMPLATE" "MYSQL_SETUP_APP" "1")
template+="$env_var"
fi
if [ -n "$MYSQLD_INSTRUMENTATION" ]; then
env_var="$(printf "$ENV_VAR_TEMPLATE" "MYSQLD_INSTRUMENTATION" "$MYSQLD_INSTRUMENTATION")"
template+="$env_var"
fi

BASE_DOCKER_COMPOSE_FILE+="$template"

Expand Down
8 changes: 4 additions & 4 deletions resources/entrypoints/mysqld.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ echo '[Entrypoint] Database initialized'
export MYSQLD_PARENT_PID=$$
if [ -z $MYSQL_SETUP_APP ]; then
echo '[Entrypoint] Not setting up app here; going straight to execution of mysqld'
echo "[Entrypoint] Running: $@"
exec "$@"
echo "[Entrypoint] Running: $MYSQLD_INSTRUMENTATION $@"
exec $MYSQLD_INSTRUMENTATION "$@"
fi

echo '[Entrypoint] Executing mysqld as daemon with no networking allowed...'
Expand Down Expand Up @@ -172,5 +172,5 @@ mysqladmin -uroot --password=$MYSQL_ROOT_PASSWORD shutdown --socket="$SOCKET"
echo "[Entrypoint] Successfully shut down MySQLd"

echo '[Entrypoint] MySQL init process done. Ready for start up.'
echo "[Entrypoint] Running: $@"
exec "$@"
echo "[Entrypoint] Running: $MYSQLD_INSTRUMENTATION $@"
exec $MYSQLD_INSTRUMENTATION "$@"