-
Notifications
You must be signed in to change notification settings - Fork 891
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 #5091
- Loading branch information
Showing
10 changed files
with
183 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,83 @@ | ||
-- 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, application_name FROM pg_stat_activity | ||
WHERE application_name LIKE 'TimescaleDB%' | ||
ORDER BY datname, 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 pg_sleep(10); -- Wait for scheduler to start. | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
SELECT * 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.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; | ||
datname | 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; | ||
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) | ||
|
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,39 @@ | ||
-- 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, application_name FROM pg_stat_activity | ||
WHERE application_name LIKE 'TimescaleDB%' | ||
ORDER BY datname, application_name; | ||
|
||
SHOW timescaledb.bgw_scheduler_restart_time; | ||
|
||
SELECT _timescaledb_functions.start_background_workers(); | ||
|
||
SELECT pg_sleep(10); -- Wait for scheduler to start. | ||
|
||
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; | ||
|
||
SELECT pg_terminate_backend(pid) | ||
FROM pg_stat_activity | ||
WHERE datname = :'TEST_DBNAME' | ||
AND application_name LIKE 'TimescaleDB%'; |