Skip to content

Commit 1912ed8

Browse files
authored
fix: restart PG during pre-upgrade steps to shed hanging connections (#1271)
1 parent 82152fa commit 1912ed8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ swap_postgres_and_supabase_admin() {
9191
alter database postgres connection limit 0;
9292
select pg_terminate_backend(pid) from pg_stat_activity where backend_type = 'client backend' and pid != pg_backend_pid();
9393
EOSQL
94+
95+
if [ -z "$IS_CI" ]; then
96+
retry 5 systemctl restart postgresql
97+
else
98+
CI_start_postgres ""
99+
fi
100+
101+
retry 8 pg_isready -h localhost -U supabase_admin
102+
94103
run_sql <<'EOSQL'
95104
set statement_timeout = '600s';
96105
begin;

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ cleanup() {
147147
}
148148

149149
function handle_extensions {
150+
if [ -z "$IS_CI" ]; then
151+
retry 5 systemctl restart postgresql
152+
else
153+
CI_start_postgres
154+
fi
155+
156+
retry 8 pg_isready -h localhost -U supabase_admin
157+
150158
rm -f $POST_UPGRADE_EXTENSION_SCRIPT
151159
touch $POST_UPGRADE_EXTENSION_SCRIPT
152160

0 commit comments

Comments
 (0)