Skip to content

Commit

Permalink
Disable replication start on initialization
Browse files Browse the repository at this point in the history
START REPLIA was inssued during initializing which mean that
even before /docker-entrypoint/initdb.d there was initializtion
going on.

Entrypoints that needed data initialzation didn't complete with
this nicely. Also if there wasn't any initialization there
would be little time for the replication to acheive anything
before being shutdown ready for the final start.

Moved --skip-slave-start to the default docker_temp_server_start
implementation.

Closes #614
  • Loading branch information
grooverdan committed Sep 4, 2024
1 parent afb3ee5 commit fa5b9d8
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 77 deletions.
10 changes: 3 additions & 7 deletions 10.11-ubi/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mysql_get_config() {
docker_temp_server_start() {
"$@" --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}" --wsrep_on=OFF \
--expire-logs-days=0 \
--skip-slave-start \
--loose-innodb_buffer_pool_load_at_startup=0 \
&
declare -g MARIADB_PID
Expand Down Expand Up @@ -458,7 +459,6 @@ docker_setup_db() {
# To create replica user
local createReplicaUser=
local changeMasterTo=
local startReplica=
if [ -n "$MARIADB_REPLICATION_USER" ] ; then
if [ -z "$MARIADB_MASTER_HOST" ]; then
# on master
Expand All @@ -471,7 +471,6 @@ docker_setup_db() {
# SC cannot follow how MARIADB_MASTER_PORT is assigned a default value.
# shellcheck disable=SC2153
changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$rplPasswordEscaped', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"
startReplica="START REPLICA;"
fi
fi

Expand Down Expand Up @@ -502,7 +501,6 @@ docker_setup_db() {
${userGrants}
${changeMasterTo}
${startReplica}
EOSQL
}

Expand Down Expand Up @@ -598,8 +596,7 @@ docker_mariadb_upgrade() {
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."

docker_mariadb_backup_system
Expand All @@ -624,8 +621,7 @@ EOSQL
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
Expand Down
10 changes: 3 additions & 7 deletions 10.11/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mysql_get_config() {
docker_temp_server_start() {
"$@" --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}" --wsrep_on=OFF \
--expire-logs-days=0 \
--skip-slave-start \
--loose-innodb_buffer_pool_load_at_startup=0 \
&
declare -g MARIADB_PID
Expand Down Expand Up @@ -458,7 +459,6 @@ docker_setup_db() {
# To create replica user
local createReplicaUser=
local changeMasterTo=
local startReplica=
if [ -n "$MARIADB_REPLICATION_USER" ] ; then
if [ -z "$MARIADB_MASTER_HOST" ]; then
# on master
Expand All @@ -471,7 +471,6 @@ docker_setup_db() {
# SC cannot follow how MARIADB_MASTER_PORT is assigned a default value.
# shellcheck disable=SC2153
changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$rplPasswordEscaped', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"
startReplica="START REPLICA;"
fi
fi

Expand Down Expand Up @@ -502,7 +501,6 @@ docker_setup_db() {
${userGrants}
${changeMasterTo}
${startReplica}
EOSQL
}

Expand Down Expand Up @@ -598,8 +596,7 @@ docker_mariadb_upgrade() {
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."

docker_mariadb_backup_system
Expand All @@ -624,8 +621,7 @@ EOSQL
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
Expand Down
10 changes: 3 additions & 7 deletions 10.5/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mysql_get_config() {
docker_temp_server_start() {
"$@" --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}" --wsrep_on=OFF \
--expire-logs-days=0 \
--skip-slave-start \
--loose-innodb_buffer_pool_load_at_startup=0 \
&
declare -g MARIADB_PID
Expand Down Expand Up @@ -449,7 +450,6 @@ docker_setup_db() {
# To create replica user
local createReplicaUser=
local changeMasterTo=
local startReplica=
if [ -n "$MARIADB_REPLICATION_USER" ] ; then
if [ -z "$MARIADB_MASTER_HOST" ]; then
# on master
Expand All @@ -462,7 +462,6 @@ docker_setup_db() {
# SC cannot follow how MARIADB_MASTER_PORT is assigned a default value.
# shellcheck disable=SC2153
changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$rplPasswordEscaped', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"
startReplica="START REPLICA;"
fi
fi

Expand Down Expand Up @@ -493,7 +492,6 @@ docker_setup_db() {
${userGrants}
${changeMasterTo}
${startReplica}
EOSQL
}

Expand Down Expand Up @@ -589,8 +587,7 @@ docker_mariadb_upgrade() {
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."

docker_mariadb_backup_system
Expand All @@ -615,8 +612,7 @@ EOSQL
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
Expand Down
10 changes: 3 additions & 7 deletions 10.6-ubi/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mysql_get_config() {
docker_temp_server_start() {
"$@" --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}" --wsrep_on=OFF \
--expire-logs-days=0 \
--skip-slave-start \
--loose-innodb_buffer_pool_load_at_startup=0 \
&
declare -g MARIADB_PID
Expand Down Expand Up @@ -450,7 +451,6 @@ docker_setup_db() {
# To create replica user
local createReplicaUser=
local changeMasterTo=
local startReplica=
if [ -n "$MARIADB_REPLICATION_USER" ] ; then
if [ -z "$MARIADB_MASTER_HOST" ]; then
# on master
Expand All @@ -463,7 +463,6 @@ docker_setup_db() {
# SC cannot follow how MARIADB_MASTER_PORT is assigned a default value.
# shellcheck disable=SC2153
changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$rplPasswordEscaped', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"
startReplica="START REPLICA;"
fi
fi

Expand Down Expand Up @@ -494,7 +493,6 @@ docker_setup_db() {
${userGrants}
${changeMasterTo}
${startReplica}
EOSQL
}

Expand Down Expand Up @@ -590,8 +588,7 @@ docker_mariadb_upgrade() {
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."

docker_mariadb_backup_system
Expand All @@ -616,8 +613,7 @@ EOSQL
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
Expand Down
10 changes: 3 additions & 7 deletions 10.6/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mysql_get_config() {
docker_temp_server_start() {
"$@" --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}" --wsrep_on=OFF \
--expire-logs-days=0 \
--skip-slave-start \
--loose-innodb_buffer_pool_load_at_startup=0 \
&
declare -g MARIADB_PID
Expand Down Expand Up @@ -450,7 +451,6 @@ docker_setup_db() {
# To create replica user
local createReplicaUser=
local changeMasterTo=
local startReplica=
if [ -n "$MARIADB_REPLICATION_USER" ] ; then
if [ -z "$MARIADB_MASTER_HOST" ]; then
# on master
Expand All @@ -463,7 +463,6 @@ docker_setup_db() {
# SC cannot follow how MARIADB_MASTER_PORT is assigned a default value.
# shellcheck disable=SC2153
changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$rplPasswordEscaped', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"
startReplica="START REPLICA;"
fi
fi

Expand Down Expand Up @@ -494,7 +493,6 @@ docker_setup_db() {
${userGrants}
${changeMasterTo}
${startReplica}
EOSQL
}

Expand Down Expand Up @@ -590,8 +588,7 @@ docker_mariadb_upgrade() {
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."

docker_mariadb_backup_system
Expand All @@ -616,8 +613,7 @@ EOSQL
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
Expand Down
10 changes: 3 additions & 7 deletions 11.2/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mysql_get_config() {
docker_temp_server_start() {
"$@" --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}" --wsrep_on=OFF \
--expire-logs-days=0 \
--skip-slave-start \
--loose-innodb_buffer_pool_load_at_startup=0 \
&
declare -g MARIADB_PID
Expand Down Expand Up @@ -458,7 +459,6 @@ docker_setup_db() {
# To create replica user
local createReplicaUser=
local changeMasterTo=
local startReplica=
if [ -n "$MARIADB_REPLICATION_USER" ] ; then
if [ -z "$MARIADB_MASTER_HOST" ]; then
# on master
Expand All @@ -471,7 +471,6 @@ docker_setup_db() {
# SC cannot follow how MARIADB_MASTER_PORT is assigned a default value.
# shellcheck disable=SC2153
changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$rplPasswordEscaped', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"
startReplica="START REPLICA;"
fi
fi

Expand Down Expand Up @@ -502,7 +501,6 @@ docker_setup_db() {
${userGrants}
${changeMasterTo}
${startReplica}
EOSQL
}

Expand Down Expand Up @@ -598,8 +596,7 @@ docker_mariadb_upgrade() {
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."

docker_mariadb_backup_system
Expand All @@ -624,8 +621,7 @@ EOSQL
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
Expand Down
10 changes: 3 additions & 7 deletions 11.4-ubi/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mysql_get_config() {
docker_temp_server_start() {
"$@" --skip-networking --default-time-zone=SYSTEM --socket="${SOCKET}" --wsrep_on=OFF \
--expire-logs-days=0 \
--skip-slave-start \
--loose-innodb_buffer_pool_load_at_startup=0 \
--skip-ssl --ssl-cert='' --ssl-key='' --ssl-ca='' \
&
Expand Down Expand Up @@ -460,7 +461,6 @@ docker_setup_db() {
# To create replica user
local createReplicaUser=
local changeMasterTo=
local startReplica=
if [ -n "$MARIADB_REPLICATION_USER" ] ; then
if [ -z "$MARIADB_MASTER_HOST" ]; then
# on master
Expand All @@ -473,7 +473,6 @@ docker_setup_db() {
# SC cannot follow how MARIADB_MASTER_PORT is assigned a default value.
# shellcheck disable=SC2153
changeMasterTo="CHANGE MASTER TO MASTER_HOST='$MARIADB_MASTER_HOST', MASTER_USER='$MARIADB_REPLICATION_USER', MASTER_PASSWORD='$rplPasswordEscaped', MASTER_PORT=$MARIADB_MASTER_PORT, MASTER_CONNECT_RETRY=10;"
startReplica="START REPLICA;"
fi
fi

Expand Down Expand Up @@ -504,7 +503,6 @@ docker_setup_db() {
${userGrants}
${changeMasterTo}
${startReplica}
EOSQL
}

Expand Down Expand Up @@ -600,8 +598,7 @@ docker_mariadb_upgrade() {
fi
mysql_note "Starting temporary server"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
mysql_note "Temporary server started."

docker_mariadb_backup_system
Expand All @@ -626,8 +623,7 @@ EOSQL
# need a restart as FLUSH PRIVILEGES isn't reversable
mysql_note "Restarting temporary server for upgrade"
docker_temp_server_start "$@" --skip-grant-tables \
--loose-innodb_buffer_pool_dump_at_shutdown=0 \
--skip-slave-start
--loose-innodb_buffer_pool_dump_at_shutdown=0
else
return 0
fi
Expand Down
Loading

0 comments on commit fa5b9d8

Please sign in to comment.