mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
MDEV-10004: Galera's pc.recovery process fails in 10.1 with systemd
Galera recovery process works in two phases. In the first phase, mysqld is started as non-daemon with --wsrep-recover to recover and fetch the last logged global transaction ID. This ID is then used in second phase as the start position (--wsrep-start-position=XX) to start mysqld as daemon. As this process was implemented in mysqld_safe script, the recovery did not work when server was started using systemd. Fixed by introducing a shell script (wsrep_recovery.sh) that mimics the first phase of the recovery process.
This commit is contained in:
parent
0645699060
commit
a6816995ee
4 changed files with 152 additions and 4 deletions
|
|
@ -48,6 +48,14 @@ CapabilityBoundingSet=CAP_IPC_LOCK
|
|||
# Execute pre and post scripts as root, otherwise it does it as User=
|
||||
PermissionsStartOnly=true
|
||||
|
||||
# Perform automatic wsrep recovery. When server is started without wsrep,
|
||||
# galera_recovery simply returns an empty string. In any case, however,
|
||||
# the script is not expected to return with a non-zero status.
|
||||
# It is always safe to unset _WSREP_START_POSITION environment variable.
|
||||
ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION"
|
||||
ExecStartPre=/bin/sh -c "VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && \
|
||||
systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1"
|
||||
|
||||
# Needed to create system tables etc.
|
||||
# ExecStartPre=/usr/bin/mysql_install_db -u mysql
|
||||
|
||||
|
|
@ -57,9 +65,12 @@ PermissionsStartOnly=true
|
|||
# This isn't a replacement for my.cnf.
|
||||
# _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster
|
||||
@SYSTEMD_EXECSTARTPRE@
|
||||
ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
|
||||
ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION
|
||||
@SYSTEMD_EXECSTARTPOST@
|
||||
|
||||
# Unset _WSREP_START_POSITION environment variable.
|
||||
ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION"
|
||||
|
||||
KillMode=process
|
||||
KillSignal=SIGTERM
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,21 @@ CapabilityBoundingSet=CAP_IPC_LOCK
|
|||
# Execute pre and post scripts as root, otherwise it does it as User=
|
||||
PermissionsStartOnly=true
|
||||
|
||||
# Perform automatic wsrep recovery. When server is started without wsrep,
|
||||
# galera_recovery simply returns an empty string. In any case, however,
|
||||
# the script is not expected to return with a non-zero status.
|
||||
# It is always safe to unset _WSREP_START_POSITION%I environment variable.
|
||||
ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I"
|
||||
ExecStartPre=/bin/sh -c "VAR=`/usr/bin/galera_recovery \
|
||||
--defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf`; [ $? -eq 0 ] && \
|
||||
systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1"
|
||||
# Alternate: (remove ConditionPathExists above)
|
||||
# use [mysqld.INSTANCENAME] as sections in my.cnf
|
||||
#
|
||||
#ExecStartPre=/bin/sh -c "VAR=`/usr/bin/galera_recovery \
|
||||
# --defaults-group-suffix=%I`; [ $? -eq 0 ] && \
|
||||
# systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1"
|
||||
|
||||
# Needed to create system tables etc.
|
||||
# ExecStartPre=/usr/bin/mysql_install_db -u mysql
|
||||
|
||||
|
|
@ -67,12 +82,15 @@ PermissionsStartOnly=true
|
|||
# Note: Place $MYSQLD_OPTS at the very end for its options to take precedence.
|
||||
|
||||
ExecStart=/usr/sbin/mysqld --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf \
|
||||
$_WSREP_NEW_CLUSTER $MYSQLD_OPTS
|
||||
$_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS
|
||||
# Alternate: (remove ConditionPathExists above)
|
||||
# use [mysqld.INSTANCENAME] as sections in my.cnf
|
||||
#
|
||||
# ExecStart=/usr/sbin/mysqld --defaults-group-suffix=%I \
|
||||
# $_WSREP_NEW_CLUSTER $MYSQLD_OPTS
|
||||
# $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS
|
||||
|
||||
# Unset _WSREP_START_POSITION environment variable.
|
||||
ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I"
|
||||
|
||||
KillMode=process
|
||||
KillSignal=SIGTERM
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue