Skip to content

Commit

Permalink
Reduce drop_extension test flakiness
Browse files Browse the repository at this point in the history
In this regression test we check the `DROP SCHEMA public CASCADE;` for
removing the extension objects stored in that schema. The problem is if
at the same moment we're running a background job it will lead to a
deadlock because the scheduler maintain information about each execution
in the metadata tables that should be part of the cascade schema
removal.

Forced stop the background jobs and also terminate any running job.

https://github.com/timescale/timescaledb/actions/runs/9424506293/job/25964852620
  • Loading branch information
fabriziomello committed Jun 12, 2024
1 parent be15ae6 commit c2a85b1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
17 changes: 16 additions & 1 deletion test/expected/drop_extension.out
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,22 @@ SELECT * FROM drop_test;

--test drops thru cascades of other objects
\c :TEST_DBNAME :ROLE_SUPERUSER
drop schema public cascade;
-- Stop background workers to prevent them from interfering with the drop public schema
SELECT _timescaledb_functions.stop_background_workers();
stop_background_workers
-------------------------
t
(1 row)

SET client_min_messages TO ERROR;
REVOKE CONNECT ON DATABASE :TEST_DBNAME FROM public;
SELECT count(pg_terminate_backend(pg_stat_activity.pid)) AS TERMINATED
FROM pg_stat_activity
WHERE pg_stat_activity.datname = :'TEST_DBNAME'
AND pg_stat_activity.pid <> pg_backend_pid() \gset
RESET client_min_messages;
-- drop the public schema and all its objects
DROP SCHEMA public CASCADE;
NOTICE: drop cascades to 3 other objects
\dn
List of schemas
Expand Down
13 changes: 11 additions & 2 deletions test/sql/drop_extension.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ SELECT * FROM drop_test;

--test drops thru cascades of other objects
\c :TEST_DBNAME :ROLE_SUPERUSER

drop schema public cascade;
-- Stop background workers to prevent them from interfering with the drop public schema
SELECT _timescaledb_functions.stop_background_workers();
SET client_min_messages TO ERROR;
REVOKE CONNECT ON DATABASE :TEST_DBNAME FROM public;
SELECT count(pg_terminate_backend(pg_stat_activity.pid)) AS TERMINATED
FROM pg_stat_activity
WHERE pg_stat_activity.datname = :'TEST_DBNAME'
AND pg_stat_activity.pid <> pg_backend_pid() \gset
RESET client_min_messages;
-- drop the public schema and all its objects
DROP SCHEMA public CASCADE;
\dn

0 comments on commit c2a85b1

Please sign in to comment.