Skip to content

Commit

Permalink
fix: restart PG during pre-upgrade steps to shed hanging connections (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pcnc authored Oct 16, 2024
1 parent 82152fa commit 1912ed8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ swap_postgres_and_supabase_admin() {
alter database postgres connection limit 0;
select pg_terminate_backend(pid) from pg_stat_activity where backend_type = 'client backend' and pid != pg_backend_pid();
EOSQL

if [ -z "$IS_CI" ]; then
retry 5 systemctl restart postgresql
else
CI_start_postgres ""
fi

retry 8 pg_isready -h localhost -U supabase_admin

run_sql <<'EOSQL'
set statement_timeout = '600s';
begin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ cleanup() {
}

function handle_extensions {
if [ -z "$IS_CI" ]; then
retry 5 systemctl restart postgresql
else
CI_start_postgres
fi

retry 8 pg_isready -h localhost -U supabase_admin

rm -f $POST_UPGRADE_EXTENSION_SCRIPT
touch $POST_UPGRADE_EXTENSION_SCRIPT

Expand Down

0 comments on commit 1912ed8

Please sign in to comment.