forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If the scheduler receives an error, it will never restart again since `bgw_restart_time` is set to `BGW_NEVER_RESTART`, which will prevent all jobs from executing. This commit fixes the issue by adding a GUC that can be set to the restart time for the scheduler, and set the default to 30 seconds. It also adds some additional variables to be able to shutdown the scheduler with a non-zero exit code, which allows the restart functionality to be tested, as well as tests. Fixes timescale#5091
- Loading branch information
Showing
10 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implements: #6195 Restart scheduler on error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
-- This file and its contents are licensed under the Timescale License. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-TIMESCALE for a copy of the license. | ||
\c :TEST_DBNAME :ROLE_SUPERUSER | ||
-- There is going to be one scheduler for each database, but we only | ||
-- care if there is zero (all schedulers shut down) or at least one | ||
-- (schedulers should be automatically restarted). | ||
CREATE VIEW tsdb_bgw AS | ||
SELECT DISTINCT application_name FROM pg_stat_activity | ||
WHERE application_name LIKE 'TimescaleDB%' | ||
ORDER BY application_name; | ||
SHOW timescaledb.bgw_scheduler_restart_time; | ||
timescaledb.bgw_scheduler_restart_time | ||
---------------------------------------- | ||
30s | ||
(1 row) | ||
|
||
SELECT _timescaledb_functions.start_background_workers(); | ||
start_background_workers | ||
-------------------------- | ||
t | ||
(1 row) | ||
|
||
SELECT * FROM tsdb_bgw; | ||
application_name | ||
----------------------------------------- | ||
TimescaleDB Background Worker Launcher | ||
TimescaleDB Background Worker Scheduler | ||
(2 rows) | ||
|
||
ALTER SYSTEM SET timescaledb.shutdown_bgw_scheduler TO 'on'; | ||
ALTER SYSTEM SET timescaledb.shutdown_bgw_scheduler_exit_code TO 1; | ||
SELECT pg_reload_conf(); | ||
pg_reload_conf | ||
---------------- | ||
t | ||
(1 row) | ||
|
||
SELECT pg_sleep(20); -- Wait for scheduler to exit. | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
SELECT * FROM tsdb_bgw; | ||
application_name | ||
---------------------------------------- | ||
TimescaleDB Background Worker Launcher | ||
(1 row) | ||
|
||
ALTER SYSTEM RESET timescaledb.shutdown_bgw_scheduler; | ||
ALTER SYSTEM RESET timescaledb.shutdown_bgw_scheduler_exit_code; | ||
SELECT pg_reload_conf(); | ||
pg_reload_conf | ||
---------------- | ||
t | ||
(1 row) | ||
|
||
SELECT pg_sleep(30); -- Wait for scheduler to restart. | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
SELECT * FROM tsdb_bgw; | ||
application_name | ||
----------------------------------------- | ||
TimescaleDB Background Worker Launcher | ||
TimescaleDB Background Worker Scheduler | ||
(2 rows) | ||
|
||
ALTER SYSTEM SET timescaledb.shutdown_bgw_scheduler TO 'on'; | ||
SELECT pg_reload_conf(); | ||
pg_reload_conf | ||
---------------- | ||
t | ||
(1 row) | ||
|
||
SELECT _timescaledb_functions.stop_background_workers(); | ||
stop_background_workers | ||
------------------------- | ||
t | ||
(1 row) | ||
|
||
SELECT pg_sleep(20); | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- This file and its contents are licensed under the Timescale License. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-TIMESCALE for a copy of the license. | ||
|
||
\c :TEST_DBNAME :ROLE_SUPERUSER | ||
|
||
-- There is going to be one scheduler for each database, but we only | ||
-- care if there is zero (all schedulers shut down) or at least one | ||
-- (schedulers should be automatically restarted). | ||
CREATE VIEW tsdb_bgw AS | ||
SELECT DISTINCT application_name FROM pg_stat_activity | ||
WHERE application_name LIKE 'TimescaleDB%' | ||
ORDER BY application_name; | ||
|
||
SHOW timescaledb.bgw_scheduler_restart_time; | ||
|
||
SELECT _timescaledb_functions.start_background_workers(); | ||
|
||
SELECT * FROM tsdb_bgw; | ||
|
||
ALTER SYSTEM SET timescaledb.shutdown_bgw_scheduler TO 'on'; | ||
ALTER SYSTEM SET timescaledb.shutdown_bgw_scheduler_exit_code TO 1; | ||
SELECT pg_reload_conf(); | ||
|
||
SELECT pg_sleep(20); -- Wait for scheduler to exit. | ||
|
||
SELECT * FROM tsdb_bgw; | ||
|
||
ALTER SYSTEM RESET timescaledb.shutdown_bgw_scheduler; | ||
ALTER SYSTEM RESET timescaledb.shutdown_bgw_scheduler_exit_code; | ||
SELECT pg_reload_conf(); | ||
|
||
SELECT pg_sleep(30); -- Wait for scheduler to restart. | ||
|
||
SELECT * FROM tsdb_bgw; | ||
|
||
ALTER SYSTEM SET timescaledb.shutdown_bgw_scheduler TO 'on'; | ||
SELECT pg_reload_conf(); | ||
|
||
SELECT _timescaledb_functions.stop_background_workers(); | ||
SELECT pg_sleep(20); |