Fix race condition in bgw_db_scheduler

The regression test bgw_db_scheduler tests if the BGW scheduler starts a
background job after it is created. However, this only happens if the
previous instance of the BGW scheduler is no longer active. If the old
BGW scheduler instance is still running, it will pick up the job and
prevent it from starting in the current test.
This commit is contained in:
Jan Nidzwetzki 2023-09-20 16:51:13 +02:00 committed by Jan Nidzwetzki
parent abf79f47fd
commit ebaee6c46f
2 changed files with 10 additions and 0 deletions

View File

@ -276,6 +276,13 @@ SELECT application_name FROM pg_stat_activity WHERE application_name LIKE 'User-
------------------
(0 rows)
-- wait for scheduler finish
SELECT ts_bgw_db_scheduler_test_wait_for_scheduler_finish();
ts_bgw_db_scheduler_test_wait_for_scheduler_finish
----------------------------------------------------
(1 row)
--
-- Test running a normal job
--

View File

@ -185,6 +185,9 @@ SELECT delete_job(:job_id);
RESET client_min_messages;
SELECT application_name FROM pg_stat_activity WHERE application_name LIKE 'User-Defined Action%';
-- wait for scheduler finish
SELECT ts_bgw_db_scheduler_test_wait_for_scheduler_finish();
--
-- Test running a normal job
--