Skip to content

Commit

Permalink
fix(pg_upgrade): retry commands within the cleanup step; wait until P…
Browse files Browse the repository at this point in the history
…G is ready to accept connections (#1251)
  • Loading branch information
pcnc authored Oct 2, 2024
1 parent 270c1c2 commit 26bdc46
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,22 @@ cleanup() {
CI_start_postgres
fi

retry 8 pg_isready -h localhost -U supabase_admin

echo "Re-enabling extensions"
if [ -f $POST_UPGRADE_EXTENSION_SCRIPT ]; then
run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
retry 5 run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
fi

echo "Removing SUPERUSER grant from postgres"
run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"
retry 5 run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"

echo "Resetting postgres database connection limit"
run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"
retry 5 run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"

if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
echo "Unmounting data disk from ${MOUNT_POINT}"
umount $MOUNT_POINT
retry 3 umount $MOUNT_POINT
fi
echo "$UPGRADE_STATUS" > /tmp/pg-upgrade-status

Expand Down

0 comments on commit 26bdc46

Please sign in to comment.