mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 02:23:49 +08:00
Restart launcher after bgw_scheduler_restart
If the scheduler is not restarted, it can affect other tests, so restarting it at the end of the test.
This commit is contained in:
parent
2d197a9572
commit
d496a186d0
@ -49,7 +49,12 @@ BEGIN
|
|||||||
RAISE EXCEPTION 'backend matching % did not start before timeout', pattern;
|
RAISE EXCEPTION 'backend matching % did not start before timeout', pattern;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
-- Show the default scheduler restart time
|
CREATE PROCEDURE ts_terminate_launcher() AS $$
|
||||||
|
SELECT pg_terminate_backend(pid) FROM tsdb_bgw
|
||||||
|
WHERE backend_type LIKE '%Launcher%';
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
-- Show the default scheduler restart time and set it to a lower
|
||||||
|
-- value.
|
||||||
SHOW timescaledb.bgw_scheduler_restart_time;
|
SHOW timescaledb.bgw_scheduler_restart_time;
|
||||||
timescaledb.bgw_scheduler_restart_time
|
timescaledb.bgw_scheduler_restart_time
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
@ -64,7 +69,9 @@ SELECT pg_reload_conf();
|
|||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
\c
|
-- Reconnect and check the restart time to make sure that it is
|
||||||
|
-- correct.
|
||||||
|
\c :TEST_DBNAME :ROLE_SUPERUSER
|
||||||
SHOW timescaledb.bgw_scheduler_restart_time;
|
SHOW timescaledb.bgw_scheduler_restart_time;
|
||||||
timescaledb.bgw_scheduler_restart_time
|
timescaledb.bgw_scheduler_restart_time
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
@ -79,15 +86,17 @@ SELECT datname, application_name FROM tsdb_bgw;
|
|||||||
| TimescaleDB Background Worker Launcher
|
| TimescaleDB Background Worker Launcher
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT pg_terminate_backend(pid) FROM tsdb_bgw
|
CALL ts_terminate_launcher();
|
||||||
WHERE backend_type LIKE '%Launcher%';
|
|
||||||
pg_terminate_backend
|
|
||||||
----------------------
|
|
||||||
t
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- It will restart automatically, but we wait for it to start.
|
-- It will restart automatically, but we wait for it to start.
|
||||||
CALL wait_for_some_started(1, 50, '%Launcher%');
|
CALL wait_for_some_started(1, 50, '%Launcher%');
|
||||||
|
-- Make sure that the new value of the scheduler restart time is
|
||||||
|
-- correct or the rest of the tests will fail.
|
||||||
|
SHOW timescaledb.bgw_scheduler_restart_time;
|
||||||
|
timescaledb.bgw_scheduler_restart_time
|
||||||
|
----------------------------------------
|
||||||
|
10s
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- Verify that launcher is running. If it is not, the rest of the test
|
-- Verify that launcher is running. If it is not, the rest of the test
|
||||||
-- will fail.
|
-- will fail.
|
||||||
SELECT datname, application_name FROM tsdb_bgw;
|
SELECT datname, application_name FROM tsdb_bgw;
|
||||||
@ -152,13 +161,7 @@ SELECT pid AS orig_pid FROM tsdb_bgw WHERE backend_type LIKE '%Launcher%' \gset
|
|||||||
-- Kill the launcher. Since there are new restarted schedulers, the
|
-- Kill the launcher. Since there are new restarted schedulers, the
|
||||||
-- handle could not be used to terminate them, and they would be left
|
-- handle could not be used to terminate them, and they would be left
|
||||||
-- running.
|
-- running.
|
||||||
SELECT pg_terminate_backend(pid) FROM tsdb_bgw
|
CALL ts_terminate_launcher();
|
||||||
WHERE backend_type LIKE '%Launcher%';
|
|
||||||
pg_terminate_backend
|
|
||||||
----------------------
|
|
||||||
t
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- Launcher will restart immediately, but we wait one second to give
|
-- Launcher will restart immediately, but we wait one second to give
|
||||||
-- it a chance to start.
|
-- it a chance to start.
|
||||||
CALL wait_for_some_started(1, 50, '%Launcher%');
|
CALL wait_for_some_started(1, 50, '%Launcher%');
|
||||||
@ -190,3 +193,6 @@ SELECT _timescaledb_functions.stop_background_workers();
|
|||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- We need to restart the launcher as well to read the reset
|
||||||
|
-- configuration or it will affect other tests.
|
||||||
|
CALL ts_terminate_launcher();
|
||||||
|
@ -54,23 +54,35 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
-- Show the default scheduler restart time
|
CREATE PROCEDURE ts_terminate_launcher() AS $$
|
||||||
|
SELECT pg_terminate_backend(pid) FROM tsdb_bgw
|
||||||
|
WHERE backend_type LIKE '%Launcher%';
|
||||||
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
|
-- Show the default scheduler restart time and set it to a lower
|
||||||
|
-- value.
|
||||||
SHOW timescaledb.bgw_scheduler_restart_time;
|
SHOW timescaledb.bgw_scheduler_restart_time;
|
||||||
ALTER SYSTEM SET timescaledb.bgw_scheduler_restart_time TO '10s';
|
ALTER SYSTEM SET timescaledb.bgw_scheduler_restart_time TO '10s';
|
||||||
ALTER SYSTEM SET timescaledb.debug_bgw_scheduler_exit_status TO 1;
|
ALTER SYSTEM SET timescaledb.debug_bgw_scheduler_exit_status TO 1;
|
||||||
SELECT pg_reload_conf();
|
SELECT pg_reload_conf();
|
||||||
\c
|
|
||||||
|
-- Reconnect and check the restart time to make sure that it is
|
||||||
|
-- correct.
|
||||||
|
\c :TEST_DBNAME :ROLE_SUPERUSER
|
||||||
SHOW timescaledb.bgw_scheduler_restart_time;
|
SHOW timescaledb.bgw_scheduler_restart_time;
|
||||||
|
|
||||||
-- Launcher is running, so we need to restart it for the scheduler
|
-- Launcher is running, so we need to restart it for the scheduler
|
||||||
-- restart time to take effect.
|
-- restart time to take effect.
|
||||||
SELECT datname, application_name FROM tsdb_bgw;
|
SELECT datname, application_name FROM tsdb_bgw;
|
||||||
SELECT pg_terminate_backend(pid) FROM tsdb_bgw
|
CALL ts_terminate_launcher();
|
||||||
WHERE backend_type LIKE '%Launcher%';
|
|
||||||
|
|
||||||
-- It will restart automatically, but we wait for it to start.
|
-- It will restart automatically, but we wait for it to start.
|
||||||
CALL wait_for_some_started(1, 50, '%Launcher%');
|
CALL wait_for_some_started(1, 50, '%Launcher%');
|
||||||
|
|
||||||
|
-- Make sure that the new value of the scheduler restart time is
|
||||||
|
-- correct or the rest of the tests will fail.
|
||||||
|
SHOW timescaledb.bgw_scheduler_restart_time;
|
||||||
|
|
||||||
-- Verify that launcher is running. If it is not, the rest of the test
|
-- Verify that launcher is running. If it is not, the rest of the test
|
||||||
-- will fail.
|
-- will fail.
|
||||||
SELECT datname, application_name FROM tsdb_bgw;
|
SELECT datname, application_name FROM tsdb_bgw;
|
||||||
@ -113,8 +125,7 @@ SELECT pid AS orig_pid FROM tsdb_bgw WHERE backend_type LIKE '%Launcher%' \gset
|
|||||||
-- Kill the launcher. Since there are new restarted schedulers, the
|
-- Kill the launcher. Since there are new restarted schedulers, the
|
||||||
-- handle could not be used to terminate them, and they would be left
|
-- handle could not be used to terminate them, and they would be left
|
||||||
-- running.
|
-- running.
|
||||||
SELECT pg_terminate_backend(pid) FROM tsdb_bgw
|
CALL ts_terminate_launcher();
|
||||||
WHERE backend_type LIKE '%Launcher%';
|
|
||||||
|
|
||||||
-- Launcher will restart immediately, but we wait one second to give
|
-- Launcher will restart immediately, but we wait one second to give
|
||||||
-- it a chance to start.
|
-- it a chance to start.
|
||||||
@ -132,5 +143,8 @@ SELECT (pid != :orig_pid) AS different_pid,
|
|||||||
ALTER SYSTEM RESET timescaledb.bgw_scheduler_restart_time;
|
ALTER SYSTEM RESET timescaledb.bgw_scheduler_restart_time;
|
||||||
ALTER SYSTEM RESET timescaledb.debug_bgw_scheduler_exit_status;
|
ALTER SYSTEM RESET timescaledb.debug_bgw_scheduler_exit_status;
|
||||||
SELECT pg_reload_conf();
|
SELECT pg_reload_conf();
|
||||||
|
|
||||||
SELECT _timescaledb_functions.stop_background_workers();
|
SELECT _timescaledb_functions.stop_background_workers();
|
||||||
|
|
||||||
|
-- We need to restart the launcher as well to read the reset
|
||||||
|
-- configuration or it will affect other tests.
|
||||||
|
CALL ts_terminate_launcher();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user