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 adds the GUC `timescaledb.bgw_scheduler_restart_time` that can be set to the restart time for the scheduler. It defaults to 60 seconds, which is the default restart interval for background workers PostgreSQL defines. It also adds `timescaledb.debug_bgw_scheduler_exit_status` to be able to shutdown the scheduler with a non-zero exit status, which allows the restart functionality to be tested. Fixes timescale#5091
- Loading branch information
Showing
10 changed files
with
270 additions
and
31 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,85 @@ | ||
-- 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 | ||
CREATE VIEW tsdb_bgw AS | ||
SELECT datname, pid, backend_type, application_name | ||
FROM pg_stat_activity | ||
WHERE application_name LIKE '%TimescaleDB%' | ||
ORDER BY datname, backend_type, application_name; | ||
-- Show the default scheduler restart time | ||
SHOW timescaledb.bgw_scheduler_restart_time; | ||
timescaledb.bgw_scheduler_restart_time | ||
---------------------------------------- | ||
1min | ||
(1 row) | ||
|
||
SELECT _timescaledb_functions.start_background_workers(); | ||
start_background_workers | ||
-------------------------- | ||
t | ||
(1 row) | ||
|
||
SELECT pg_sleep(10); -- Wait for scheduler to start. | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
SELECT datname, application_name FROM tsdb_bgw; | ||
datname | application_name | ||
--------------------------+----------------------------------------- | ||
db_bgw_scheduler_restart | TimescaleDB Background Worker Scheduler | ||
| TimescaleDB Background Worker Launcher | ||
(2 rows) | ||
|
||
ALTER SYSTEM SET timescaledb.shutdown_bgw_scheduler TO 'on'; | ||
ALTER SYSTEM SET timescaledb.debug_bgw_scheduler_exit_status 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 datname, application_name FROM tsdb_bgw; | ||
datname | application_name | ||
---------+---------------------------------------- | ||
| TimescaleDB Background Worker Launcher | ||
(1 row) | ||
|
||
ALTER SYSTEM RESET timescaledb.shutdown_bgw_scheduler; | ||
ALTER SYSTEM RESET timescaledb.debug_bgw_scheduler_exit_status; | ||
SELECT pg_reload_conf(); | ||
pg_reload_conf | ||
---------------- | ||
t | ||
(1 row) | ||
|
||
SELECT pg_sleep(60); -- Wait for scheduler to restart. | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
SELECT datname, application_name FROM tsdb_bgw; | ||
datname | application_name | ||
--------------------------+----------------------------------------- | ||
db_bgw_scheduler_restart | TimescaleDB Background Worker Scheduler | ||
| TimescaleDB Background Worker Launcher | ||
(2 rows) | ||
|
||
SELECT pg_terminate_backend(pid) | ||
FROM pg_stat_activity | ||
WHERE datname = :'TEST_DBNAME' | ||
AND application_name LIKE 'TimescaleDB%'; | ||
pg_terminate_backend | ||
---------------------- | ||
t | ||
(1 row) | ||
|
Oops, something went wrong.