Skip to content

Commit 26bdc46

Browse files
authored
fix(pg_upgrade): retry commands within the cleanup step; wait until PG is ready to accept connections (#1251)
1 parent 270c1c2 commit 26bdc46

File tree

1 file changed

+6
-4
lines changed
  • ansible/files/admin_api_scripts/pg_upgrade_scripts

1 file changed

+6
-4
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,22 @@ cleanup() {
120120
CI_start_postgres
121121
fi
122122

123+
retry 8 pg_isready -h localhost -U supabase_admin
124+
123125
echo "Re-enabling extensions"
124126
if [ -f $POST_UPGRADE_EXTENSION_SCRIPT ]; then
125-
run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
127+
retry 5 run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
126128
fi
127129

128130
echo "Removing SUPERUSER grant from postgres"
129-
run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"
131+
retry 5 run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"
130132

131133
echo "Resetting postgres database connection limit"
132-
run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"
134+
retry 5 run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"
133135

134136
if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
135137
echo "Unmounting data disk from ${MOUNT_POINT}"
136-
umount $MOUNT_POINT
138+
retry 3 umount $MOUNT_POINT
137139
fi
138140
echo "$UPGRADE_STATUS" > /tmp/pg-upgrade-status
139141

0 commit comments

Comments
 (0)