Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pg_upgrade): retry commands within the cleanup step; wait until PG is ready to accept connections #1251

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading