postgresql migration: Attempt to fix cluster upgrade, complaining that cluster for 13 already existed, suspecting a race condition maybe

This commit is contained in:
Alexandre Aubin 2022-01-17 23:58:04 +01:00
parent ecb8419ee0
commit 89dda11b56

View file

@ -1,4 +1,5 @@
import subprocess
import time
from moulinette import m18n
from yunohost.utils.error import YunohostError, YunohostValidationError
@ -42,9 +43,11 @@ class MyMigration(Migration):
)
self.runcmd("systemctl stop postgresql")
time.sleep(3)
self.runcmd(
"LC_ALL=C pg_dropcluster --stop 13 main || true"
) # We do not trigger an exception if the command fails because that probably means cluster 13 doesn't exists, which is fine because it's created during the pg_upgradecluster)
time.sleep(3)
self.runcmd("LC_ALL=C pg_upgradecluster -m upgrade 11 main")
self.runcmd("LC_ALL=C pg_dropcluster --stop 11 main")
self.runcmd("systemctl start postgresql")