From f8b851c188f944f4946d7edea0ca07365ef329a0 Mon Sep 17 00:00:00 2001 From: Antonin Houska Date: Mon, 18 Sep 2023 17:58:17 +0200 Subject: [PATCH] Remove an unnecessary call of start_workers() from regression test. An earlier commit teaches the squeeze_table() function to start a squeeze worker if one is not already running for given database. Thus we don't need to do so explicitly in the test script. Moreover, there seeme to be race conditions causing an error: 1) the squeeze worker is started explicitly by start_worker(), 2) squeeze_table() doesn't see the worker's "shared memory slot" initialized yet, so it also tries to start the worker, 3) the worker launched by start_worker() completes the startup, 3) the worker launched by squeeze_table() sees the first worker, so it exits immediately, 5) the squeeze_table() function receives the BGWH_STOPPED code from WaitForBackgroundWorkerStartup(), which is not expected, so it raises ERROR. --- expected/squeeze.out | 11 +++++------ sql/squeeze.sql | 7 +++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/expected/squeeze.out b/expected/squeeze.out index 69e2047..41c66bc 100644 --- a/expected/squeeze.out +++ b/expected/squeeze.out @@ -1,10 +1,4 @@ CREATE EXTENSION pg_squeeze; -SELECT squeeze.start_worker(); - start_worker --------------- - -(1 row) - CREATE TABLE a(i int PRIMARY KEY, j int); INSERT INTO a(i, j) SELECT x, x @@ -93,6 +87,11 @@ WHERE b.i = b_copy.i; t (10 rows) +-- Although squeeze_table() makes sure that the worker is started, it should +-- stop it because that would break the automatic processing of scheduled +-- tables. However we should stop the worker during tests, otherwise a +-- repeated test won't be able to drop the "contrib_regression" database, and +-- thus will fail. SELECT squeeze.stop_worker(); stop_worker ------------- diff --git a/sql/squeeze.sql b/sql/squeeze.sql index 21e9385..543d1ee 100644 --- a/sql/squeeze.sql +++ b/sql/squeeze.sql @@ -1,7 +1,5 @@ CREATE EXTENSION pg_squeeze; -SELECT squeeze.start_worker(); - CREATE TABLE a(i int PRIMARY KEY, j int); INSERT INTO a(i, j) @@ -34,4 +32,9 @@ SELECT b.t = b_copy.t FROM b, b_copy WHERE b.i = b_copy.i; +-- Although squeeze_table() makes sure that the worker is started, it should +-- stop it because that would break the automatic processing of scheduled +-- tables. However we should stop the worker during tests, otherwise a +-- repeated test won't be able to drop the "contrib_regression" database, and +-- thus will fail. SELECT squeeze.stop_worker();