mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
services.mysql: wait for galera cluster sync to be done
This commit is contained in:
parent
0ce9de036c
commit
41ec4243d1
1 changed files with 19 additions and 0 deletions
|
@ -433,6 +433,25 @@ in
|
|||
done
|
||||
''}
|
||||
|
||||
${lib.optionalString isMariaDB ''
|
||||
# If MariaDB is used in an Galera cluster, we have to check if the sync is done,
|
||||
# or it will fail to init the database while joining, so we get in an broken non recoverable state
|
||||
# so we wait until we have an synced state
|
||||
if ${cfg.package}/bin/mysql -u ${superUser} -N -e "SHOW VARIABLES LIKE 'wsrep_on'" 2>/dev/null | ${lib.getExe' pkgs.gnugrep "grep"} -q 'ON'; then
|
||||
echo "Galera cluster detected, waiting for node to be synced..."
|
||||
while true; do
|
||||
STATE=$(${cfg.package}/bin/mysql -u ${superUser} -N -e "SHOW STATUS LIKE 'wsrep_local_state_comment'" | ${lib.getExe' pkgs.gawk "awk"} '{print $2}')
|
||||
if [ "$STATE" = "Synced" ]; then
|
||||
echo "Node is synced"
|
||||
break
|
||||
else
|
||||
echo "Current state: $STATE - Waiting for 1 second..."
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
''}
|
||||
|
||||
if [ -f ${cfg.dataDir}/mysql_init ]
|
||||
then
|
||||
# While MariaDB comes with a 'mysql' super user account since 10.4.x, MySQL does not
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue