diff --git a/sql/views.sql b/sql/views.sql index 0611c0d70..6a8f7e42a 100644 --- a/sql/views.sql +++ b/sql/views.sql @@ -69,6 +69,27 @@ CREATE OR REPLACE VIEW timescaledb_information.policy_stats as INNER JOIN _timescaledb_internal.bgw_job_stat js on j.id = js.job_id ORDER BY ht.schema_name, ht.table_name; +-- view for background worker jobs +CREATE OR REPLACE VIEW timescaledb_information.jobs AS +SELECT j.id AS job_id, + j.application_name, + j.schedule_interval, + j.max_runtime, + j.max_retries, + j.retry_period, + j.proc_schema, + j.proc_name, + j.owner, + j.scheduled, + j.config, + js.next_start, + ht.schema_name AS hypertable_schema, + ht.table_name AS hypertable_name +FROM _timescaledb_config.bgw_job j + LEFT JOIN _timescaledb_catalog.hypertable ht ON ht.id = j.hypertable_id + LEFT JOIN _timescaledb_internal.bgw_job_stat js ON js.job_id = j.id +ORDER BY j.id; + -- views for continuous aggregate queries --- CREATE OR REPLACE VIEW timescaledb_information.continuous_aggregates as SELECT format('%1$I.%2$I', cagg.user_view_schema, cagg.user_view_name)::regclass as view_name, diff --git a/test/expected/pg_dump.out b/test/expected/pg_dump.out index d99518156..cf5ecf0f4 100644 --- a/test/expected/pg_dump.out +++ b/test/expected/pg_dump.out @@ -540,6 +540,7 @@ WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND timescaledb_information.chunks timescaledb_information.data_node timescaledb_information.continuous_aggregates + timescaledb_information.jobs timescaledb_information.policy_stats timescaledb_information.license timescaledb_information.hypertables @@ -549,7 +550,7 @@ WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND _timescaledb_internal.bgw_policy_chunk_stats _timescaledb_internal.bgw_job_stat _timescaledb_catalog.tablespace_id_seq -(14 rows) +(15 rows) -- Make sure we can't run our restoring functions as a normal perm user as that would disable functionality for the whole db \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER diff --git a/tsl/test/expected/bgw_custom.out b/tsl/test/expected/bgw_custom.out index e0b788f6d..e22e0c8e4 100644 --- a/tsl/test/expected/bgw_custom.out +++ b/tsl/test/expected/bgw_custom.out @@ -56,6 +56,17 @@ SELECT add_job('custom_func_definer', '1h', config:='{"type":"function"}'::jsonb 1004 (1 row) +SELECT * FROM timescaledb_information.jobs ORDER BY 1; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+---------------------+-------------------+-----------+-----------------------+------------+-------------------+----------------- + 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | t | | | | + 1000 | Custom Job [1000] | @ 1 hour | @ 0 | -1 | @ 5 mins | public | custom_func | default_perm_user | t | {"type": "function"} | | | + 1001 | Custom Job [1001] | @ 1 hour | @ 0 | -1 | @ 5 mins | public | custom_proc | default_perm_user | t | {"type": "procedure"} | | | + 1002 | Custom Job [1002] | @ 1 hour | @ 0 | -1 | @ 5 mins | public | custom_proc2 | default_perm_user | t | {"type": "procedure"} | | | + 1003 | Custom Job [1003] | @ 1 hour | @ 0 | -1 | @ 5 mins | public | custom_func | default_perm_user | t | {"type": "function"} | | | + 1004 | Custom Job [1004] | @ 1 hour | @ 0 | -1 | @ 5 mins | public | custom_func_definer | default_perm_user | t | {"type": "function"} | | | +(6 rows) + CALL run_job(1000); CALL run_job(1001); CALL run_job(1002); @@ -103,10 +114,11 @@ SELECT delete_job(1004); (1 row) -- check jobs got removed -SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- -(0 rows) +SELECT count(*) FROM timescaledb_information.jobs WHERE job_id >= 1000; + count +------- + 0 +(1 row) \c :TEST_DBNAME :ROLE_SUPERUSER -- test altering job with NULL config @@ -116,10 +128,10 @@ SELECT job_id FROM alter_job(1,scheduled:=false); 1 (1 row) -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+---------------+-------- - 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | f | | +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+--------+------------+-------------------+----------------- + 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | f | | | | (1 row) -- test updating job settings @@ -129,10 +141,10 @@ SELECT job_id FROM alter_job(1,config:='{"test":"test"}'); 1 (1 row) -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+---------------+------------------ - 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | f | | {"test": "test"} +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+------------------+------------+-------------------+----------------- + 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | f | {"test": "test"} | | | (1 row) SELECT job_id FROM alter_job(1,scheduled:=true); @@ -141,10 +153,10 @@ SELECT job_id FROM alter_job(1,scheduled:=true); 1 (1 row) -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+---------------+------------------ - 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | t | | {"test": "test"} +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+------------------+------------+-------------------+----------------- + 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | t | {"test": "test"} | | | (1 row) SELECT job_id FROM alter_job(1,scheduled:=false); @@ -153,9 +165,9 @@ SELECT job_id FROM alter_job(1,scheduled:=false); 1 (1 row) -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+---------------+------------------ - 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | f | | {"test": "test"} +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+------------------------+-------------------+-----------------+-------------+--------------+-----------------------+------------------+------------+-----------+------------------+------------+-------------------+----------------- + 1 | Telemetry Reporter [1] | @ 24 hours | @ 1 min 40 secs | -1 | @ 1 hour | _timescaledb_internal | policy_telemetry | super_user | f | {"test": "test"} | | | (1 row) diff --git a/tsl/test/expected/bgw_reorder_drop_chunks.out b/tsl/test/expected/bgw_reorder_drop_chunks.out index 16d7ce158..3db6e7638 100644 --- a/tsl/test/expected/bgw_reorder_drop_chunks.out +++ b/tsl/test/expected/bgw_reorder_drop_chunks.out @@ -21,7 +21,7 @@ AS :MODULE_PATHNAME LANGUAGE C VOLATILE; \set IMMEDIATELY_SET_UNTIL 1 \set WAIT_FOR_OTHER_TO_ADVANCE 2 -- Remove any default jobs, e.g., telemetry -DELETE FROM _timescaledb_config.bgw_job WHERE TRUE; +DELETE FROM _timescaledb_config.bgw_job; TRUNCATE _timescaledb_internal.bgw_job_stat; \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER CREATE TABLE public.bgw_log( @@ -101,10 +101,10 @@ SELECT json_object_field(get_telemetry_report(always_display_report := true)::js (1 row) -- job was created -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+------------------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+-------------------------------------------------------------------+------------+-------------------+-------------------- + 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} | | public | test_reorder_table (1 row) -- no stats @@ -137,10 +137,10 @@ SELECT * FROM sorted_bgw_log; 1 | 0 | DB Scheduler | [TESTING] Wait until 25000, started at 0 (2 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+------------------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+-------------------------------------------------------------------+------------------------------+-------------------+-------------------- + 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} | Fri Dec 31 16:00:00 1999 PST | public | test_reorder_table (1 row) -- job ran once, successfully @@ -177,10 +177,10 @@ SELECT * FROM sorted_bgw_log; 1 | 25000 | DB Scheduler | [TESTING] Wait until 50000, started at 25000 (4 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+------------------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+-------------------------------------------------------------------+----------------------------------+-------------------+-------------------- + 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} | Fri Dec 31 16:00:00.025 1999 PST | public | test_reorder_table (1 row) -- two runs @@ -221,10 +221,10 @@ SELECT * FROM sorted_bgw_log; 1 | 50000 | DB Scheduler | [TESTING] Wait until 100000, started at 50000 (6 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+------------------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+-------------------------------------------------------------------+---------------------------------+-------------------+-------------------- + 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} | Tue Jan 04 16:00:00.05 2000 PST | public | test_reorder_table (1 row) SELECT * @@ -265,10 +265,10 @@ SELECT * FROM sorted_bgw_log; 0 | 100000 | DB Scheduler | [TESTING] Wait until 200000, started at 100000 (7 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+------------------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+-------------------------------------------------------------------+---------------------------------+-------------------+-------------------- + 1000 | Reorder Policy [1000] | @ 4 days | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | {"index_name": "test_reorder_table_time_idx", "hypertable_id": 1} | Tue Jan 04 16:00:00.05 2000 PST | public | test_reorder_table (1 row) SELECT * @@ -304,9 +304,9 @@ SELECT remove_reorder_policy('test_reorder_table'); (1 row) -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+--------+------------+-------------------+----------------- (0 rows) SELECT job_id, next_start, last_finish as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes @@ -335,9 +335,9 @@ SELECT * FROM sorted_bgw_log; 0 | 200000 | DB Scheduler | [TESTING] Wait until 325000, started at 200000 (8 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+--------+------------+-------------------+----------------- (0 rows) -- still only 3 chunks clustered @@ -414,10 +414,10 @@ SELECT alter_job(:drop_chunks_job_id, schedule_interval => INTERVAL '1 second'); (1001,"@ 1 sec","@ 5 mins",-1,"@ 5 mins",t,"{""hypertable_id"": 2, ""retention_window"": ""@ 4 mons""}",-infinity) (1 row) -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------------ - 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 2 | {"hypertable_id": 2, "retention_window": "@ 4 mons"} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+------------------------------------------------------+------------+-------------------+------------------------ + 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | {"hypertable_id": 2, "retention_window": "@ 4 mons"} | | public | test_drop_chunks_table (1 row) -- no stats @@ -453,10 +453,10 @@ SELECT * FROM sorted_bgw_log; 1 | 0 | DB Scheduler | [TESTING] Wait until 25000, started at 0 (2 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------------ - 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 2 | {"hypertable_id": 2, "retention_window": "@ 4 mons"} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+------------------------------------------------------+------------------------------+-------------------+------------------------ + 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | {"hypertable_id": 2, "retention_window": "@ 4 mons"} | Fri Dec 31 16:00:01 1999 PST | public | test_drop_chunks_table (1 row) -- job ran once, successfully @@ -492,10 +492,10 @@ SELECT * FROM sorted_bgw_log; 0 | 25000 | DB Scheduler | [TESTING] Wait until 50000, started at 25000 (3 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------------ - 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 2 | {"hypertable_id": 2, "retention_window": "@ 4 mons"} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+------------------------------------------------------+------------------------------+-------------------+------------------------ + 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | {"hypertable_id": 2, "retention_window": "@ 4 mons"} | Fri Dec 31 16:00:01 1999 PST | public | test_drop_chunks_table (1 row) -- still only 1 run @@ -544,10 +544,10 @@ SELECT * FROM sorted_bgw_log; 2 | 1000000 | DB Scheduler | [TESTING] Wait until 10050000, started at 1000000 (6 rows) -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------------ - 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 2 | {"hypertable_id": 2, "retention_window": "@ 4 mons"} +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; + job_id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | config | next_start | hypertable_schema | hypertable_name +--------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+------------------------------------------------------+------------------------------+-------------------+------------------------ + 1001 | Retention Policy [1001] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | {"hypertable_id": 2, "retention_window": "@ 4 mons"} | Fri Dec 31 16:00:02 1999 PST | public | test_drop_chunks_table (1 row) -- 2 runs diff --git a/tsl/test/sql/bgw_custom.sql b/tsl/test/sql/bgw_custom.sql index 95864a32d..a1da8b50c 100644 --- a/tsl/test/sql/bgw_custom.sql +++ b/tsl/test/sql/bgw_custom.sql @@ -39,6 +39,8 @@ SELECT add_job('custom_proc2','1h', config:= '{"type":"procedure"}'::jsonb); SELECT add_job('custom_func', '1h', config:='{"type":"function"}'::jsonb); SELECT add_job('custom_func_definer', '1h', config:='{"type":"function"}'::jsonb); +SELECT * FROM timescaledb_information.jobs ORDER BY 1; + CALL run_job(1000); CALL run_job(1001); CALL run_job(1002); @@ -54,17 +56,17 @@ SELECT delete_job(1003); SELECT delete_job(1004); -- check jobs got removed -SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000; +SELECT count(*) FROM timescaledb_information.jobs WHERE job_id >= 1000; \c :TEST_DBNAME :ROLE_SUPERUSER -- test altering job with NULL config SELECT job_id FROM alter_job(1,scheduled:=false); -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; -- test updating job settings SELECT job_id FROM alter_job(1,config:='{"test":"test"}'); -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; SELECT job_id FROM alter_job(1,scheduled:=true); -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; SELECT job_id FROM alter_job(1,scheduled:=false); -SELECT * FROM _timescaledb_config.bgw_job WHERE id = 1; +SELECT * FROM timescaledb_information.jobs WHERE job_id = 1; diff --git a/tsl/test/sql/bgw_reorder_drop_chunks.sql b/tsl/test/sql/bgw_reorder_drop_chunks.sql index dac7e3c5a..73bf3841a 100644 --- a/tsl/test/sql/bgw_reorder_drop_chunks.sql +++ b/tsl/test/sql/bgw_reorder_drop_chunks.sql @@ -29,7 +29,7 @@ AS :MODULE_PATHNAME LANGUAGE C VOLATILE; \set WAIT_FOR_OTHER_TO_ADVANCE 2 -- Remove any default jobs, e.g., telemetry -DELETE FROM _timescaledb_config.bgw_job WHERE TRUE; +DELETE FROM _timescaledb_config.bgw_job; TRUNCATE _timescaledb_internal.bgw_job_stat; \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER @@ -87,7 +87,7 @@ select add_reorder_policy('test_reorder_table', 'test_reorder_table_time_idx') a SELECT json_object_field(get_telemetry_report(always_display_report := true)::json,'num_reorder_policies'); -- job was created -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; -- no stats SELECT job_id, next_start, last_finish as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes @@ -104,7 +104,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(25); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; -- job ran once, successfully SELECT job_id, next_start, last_finish as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes @@ -121,7 +121,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(25); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; -- two runs SELECT job_id, next_start, last_finish as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes @@ -140,7 +140,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(50); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; SELECT * FROM _timescaledb_internal.bgw_job_stat @@ -157,7 +157,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(100); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; SELECT * FROM _timescaledb_internal.bgw_job_stat @@ -174,7 +174,7 @@ SELECT * FROM timescaledb_information.policy_stats; -- test deleting the policy SELECT remove_reorder_policy('test_reorder_table'); -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; SELECT job_id, next_start, last_finish as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes FROM _timescaledb_internal.bgw_job_stat @@ -184,7 +184,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(125); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:reorder_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:reorder_job_id; -- still only 3 chunks clustered SELECT indexrelid::regclass, indisclustered @@ -225,7 +225,7 @@ SELECT json_object_field(get_telemetry_report(always_display_report := true)::js SELECT alter_job(:drop_chunks_job_id, schedule_interval => INTERVAL '1 second'); -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; -- no stats SELECT job_id, next_start, last_finish as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes @@ -240,7 +240,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(25); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; -- job ran once, successfully SELECT job_id, time_bucket('1m',next_start) AS next_start, time_bucket('1m',last_finish) as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes @@ -255,7 +255,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(25); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; -- still only 1 run SELECT job_id, time_bucket('1m',next_start) AS next_start, time_bucket('1m',last_finish) as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes @@ -274,7 +274,7 @@ SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(10000); SELECT * FROM sorted_bgw_log; -SELECT * FROM _timescaledb_config.bgw_job where id=:drop_chunks_job_id; +SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; -- 2 runs SELECT job_id, time_bucket('1m',next_start) AS next_start, time_bucket('1m',last_finish) as until_next, last_run_success, total_runs, total_successes, total_failures, total_crashes