From 90167700ad383fa7e3db9db6b67568f14be56e29 Mon Sep 17 00:00:00 2001 From: Steve Perkins Date: Wed, 29 Jun 2022 14:49:13 -0400 Subject: [PATCH] Kill running queries before migration (#3341) * Kill running queries before migration * don't cancel self --- .../alembic/versions/38642fb2948d_add_pg_triggers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/discovery-provider/alembic/versions/38642fb2948d_add_pg_triggers.py b/discovery-provider/alembic/versions/38642fb2948d_add_pg_triggers.py index b469a58e715..63efb7ad184 100644 --- a/discovery-provider/alembic/versions/38642fb2948d_add_pg_triggers.py +++ b/discovery-provider/alembic/versions/38642fb2948d_add_pg_triggers.py @@ -26,6 +26,11 @@ def upgrade(): connection = op.get_bind() connection.execute( """ + SELECT pg_cancel_backend(pid) + FROM pg_stat_activity + WHERE state != 'idle' AND query NOT ILIKE '%pg_stat_activity%' and pid <> pg_backend_pid() + ORDER BY query_start DESC; + begin; WITH new_plays AS ( SELECT