Skip to content

Commit

Permalink
Fix bgw_launcher flakiness when dropping DB
Browse files Browse the repository at this point in the history
Revoking connection and stopping all backgrounds before attempting
to drop database at the end of the test to prevent failing the test
unnecessarily.
  • Loading branch information
antekresic committed Feb 29, 2024
1 parent d9b6505 commit 452c64d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/expected/bgw_launcher.out
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,12 @@ ALTER DATABASE :TEST_DBNAME SET TABLESPACE tablespace1;
WARNING: you may need to manually restart any running background workers after this command
-- tear down test and clean up additional database
\c :TEST_DBNAME :ROLE_SUPERUSER
SELECT _timescaledb_functions.stop_background_workers() \gset
SET client_min_messages TO ERROR;
REVOKE CONNECT ON DATABASE :TEST_DBNAME_2 FROM public;
SELECT count(pg_terminate_backend(pg_stat_activity.pid)) AS TERMINATED
FROM pg_stat_activity
WHERE pg_stat_activity.datname = :'TEST_DBNAME_2'
AND pg_stat_activity.pid <> pg_backend_pid() \gset
RESET client_min_messages;
DROP DATABASE :TEST_DBNAME_2 WITH (force);
9 changes: 9 additions & 0 deletions test/sql/bgw_launcher.sql
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,14 @@ ALTER DATABASE :TEST_DBNAME SET TABLESPACE tablespace1;
-- tear down test and clean up additional database
\c :TEST_DBNAME :ROLE_SUPERUSER

SELECT _timescaledb_functions.stop_background_workers() \gset
SET client_min_messages TO ERROR;
REVOKE CONNECT ON DATABASE :TEST_DBNAME_2 FROM public;
SELECT count(pg_terminate_backend(pg_stat_activity.pid)) AS TERMINATED
FROM pg_stat_activity
WHERE pg_stat_activity.datname = :'TEST_DBNAME_2'
AND pg_stat_activity.pid <> pg_backend_pid() \gset
RESET client_min_messages;

DROP DATABASE :TEST_DBNAME_2 WITH (force);

0 comments on commit 452c64d

Please sign in to comment.