Skip to content

Commit 7b12d1e

Browse files
committed
fixes flaky by terminating open transactions in teardown
1 parent 2bec88d commit 7b12d1e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

services/web/server/tests/unit/with_dbs/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,17 @@ def postgres_db(
527527
with engine.begin() as conn:
528528
conn.execute(sa.DDL("DROP TABLE IF EXISTS alembic_version"))
529529

530-
orm.metadata.drop_all(engine)
530+
conn.execute(
531+
# NOTE: terminates all open transactions before droping all tables
532+
# This solves https://github.com/ITISFoundation/osparc-simcore/issues/7008
533+
sa.DDL(
534+
"SELECT pg_terminate_backend(pid) "
535+
"FROM pg_stat_activity "
536+
"WHERE state = 'idle in transaction';"
537+
)
538+
)
539+
orm.metadata.drop_all(bind=conn)
540+
531541
engine.dispose()
532542

533543

0 commit comments

Comments
 (0)