diff --git a/.unreleased/feature_5758 b/.unreleased/feature_5758 new file mode 100644 index 00000000000..c3e4b2dab00 --- /dev/null +++ b/.unreleased/feature_5758 @@ -0,0 +1 @@ +Implements: #5758 Enable altering job schedule type through `alter_job` diff --git a/sql/job_api.sql b/sql/job_api.sql index 12de4912efd..ad9ddbdfae2 100644 --- a/sql/job_api.sql +++ b/sql/job_api.sql @@ -27,10 +27,13 @@ CREATE OR REPLACE FUNCTION @extschema@.alter_job( config JSONB = NULL, next_start TIMESTAMPTZ = NULL, if_exists BOOL = FALSE, - check_config REGPROC = NULL + check_config REGPROC = NULL, + fixed_schedule BOOL = NULL, + initial_start TIMESTAMPTZ = NULL, + timezone TEXT DEFAULT NULL ) RETURNS TABLE (job_id INTEGER, schedule_interval INTERVAL, max_runtime INTERVAL, max_retries INTEGER, retry_period INTERVAL, scheduled BOOL, config JSONB, -next_start TIMESTAMPTZ, check_config TEXT) +next_start TIMESTAMPTZ, check_config TEXT, fixed_schedule BOOL, initial_start TIMESTAMPTZ, timezone TEXT) AS '@MODULE_PATHNAME@', 'ts_job_alter' LANGUAGE C VOLATILE; diff --git a/sql/updates/latest-dev.sql b/sql/updates/latest-dev.sql index e69de29bb2d..35d804c3b9a 100644 --- a/sql/updates/latest-dev.sql +++ b/sql/updates/latest-dev.sql @@ -0,0 +1,32 @@ +DROP FUNCTION IF EXISTS @extschema@.alter_job( + INTEGER, + INTERVAL, + INTERVAL, + INTEGER, + INTERVAL, + BOOL, + JSONB, + TIMESTAMPTZ, + BOOL, + REGPROC +); + +CREATE FUNCTION @extschema@.alter_job( + job_id INTEGER, + schedule_interval INTERVAL = NULL, + max_runtime INTERVAL = NULL, + max_retries INTEGER = NULL, + retry_period INTERVAL = NULL, + scheduled BOOL = NULL, + config JSONB = NULL, + next_start TIMESTAMPTZ = NULL, + if_exists BOOL = FALSE, + check_config REGPROC = NULL, + fixed_schedule BOOL = NULL, + initial_start TIMESTAMPTZ = NULL, + timezone TEXT DEFAULT NULL +) +RETURNS TABLE (job_id INTEGER, schedule_interval INTERVAL, max_runtime INTERVAL, max_retries INTEGER, retry_period INTERVAL, scheduled BOOL, config JSONB, +next_start TIMESTAMPTZ, check_config TEXT, fixed_schedule BOOL, initial_start TIMESTAMPTZ, timezone TEXT) +AS '@MODULE_PATHNAME@', 'ts_job_alter' +LANGUAGE C VOLATILE; diff --git a/sql/updates/reverse-dev.sql b/sql/updates/reverse-dev.sql index e69de29bb2d..3b9516ca54f 100644 --- a/sql/updates/reverse-dev.sql +++ b/sql/updates/reverse-dev.sql @@ -0,0 +1,32 @@ +DROP FUNCTION IF EXISTS @extschema@.alter_job( + INTEGER, + INTERVAL, + INTERVAL, + INTEGER, + INTERVAL, + BOOL, + JSONB, + TIMESTAMPTZ, + BOOL, + REGPROC, + BOOL, + TIMESTAMPTZ, + TEXT +); + +CREATE FUNCTION @extschema@.alter_job( + job_id INTEGER, + schedule_interval INTERVAL = NULL, + max_runtime INTERVAL = NULL, + max_retries INTEGER = NULL, + retry_period INTERVAL = NULL, + scheduled BOOL = NULL, + config JSONB = NULL, + next_start TIMESTAMPTZ = NULL, + if_exists BOOL = FALSE, + check_config REGPROC = NULL +) +RETURNS TABLE (job_id INTEGER, schedule_interval INTERVAL, max_runtime INTERVAL, max_retries INTEGER, retry_period INTERVAL, scheduled BOOL, config JSONB, +next_start TIMESTAMPTZ, check_config TEXT) +AS '@MODULE_PATHNAME@', 'ts_job_alter' +LANGUAGE C VOLATILE; diff --git a/src/bgw/job.c b/src/bgw/job.c index cd004924c02..3947a748078 100644 --- a/src/bgw/job.c +++ b/src/bgw/job.c @@ -265,6 +265,8 @@ bgw_job_from_tupleinfo(TupleInfo *ti, size_t alloc_size) job->fd.initial_start = DatumGetTimestampTz(values[AttrNumberGetAttrOffset(Anum_bgw_job_initial_start)]); } + else + job->fd.initial_start = DT_NOBEGIN; if (!nulls[AttrNumberGetAttrOffset(Anum_bgw_job_timezone)]) job->fd.timezone = @@ -878,6 +880,10 @@ bgw_job_tuple_update_by_id(TupleInfo *ti, void *const data) BoolGetDatum(updated_job->fd.scheduled); doReplace[AttrNumberGetAttrOffset(Anum_bgw_job_scheduled)] = true; + values[AttrNumberGetAttrOffset(Anum_bgw_job_fixed_schedule)] = + BoolGetDatum(updated_job->fd.fixed_schedule); + doReplace[AttrNumberGetAttrOffset(Anum_bgw_job_fixed_schedule)] = true; + doReplace[AttrNumberGetAttrOffset(Anum_bgw_job_config)] = true; values[AttrNumberGetAttrOffset(Anum_bgw_job_check_schema)] = @@ -912,6 +918,22 @@ bgw_job_tuple_update_by_id(TupleInfo *ti, void *const data) else isnull[AttrNumberGetAttrOffset(Anum_bgw_job_hypertable_id)] = true; + if (TIMESTAMP_NOT_FINITE(updated_job->fd.initial_start)) + isnull[AttrNumberGetAttrOffset(Anum_bgw_job_initial_start)] = true; + else + values[AttrNumberGetAttrOffset(Anum_bgw_job_initial_start)] = + TimestampTzGetDatum(updated_job->fd.initial_start); + doReplace[AttrNumberGetAttrOffset(Anum_bgw_job_initial_start)] = true; + + if (updated_job->fd.timezone) + { + values[AttrNumberGetAttrOffset(Anum_bgw_job_timezone)] = + PointerGetDatum(updated_job->fd.timezone); + } + else + isnull[AttrNumberGetAttrOffset(Anum_bgw_job_timezone)] = true; + doReplace[AttrNumberGetAttrOffset(Anum_bgw_job_timezone)] = true; + new_tuple = heap_modify_tuple(tuple, ts_scanner_get_tupledesc(ti), values, isnull, doReplace); ts_catalog_update(ti->scanrel, new_tuple); diff --git a/src/bgw/job_stat.c b/src/bgw/job_stat.c index 744416d80d1..833574f4559 100644 --- a/src/bgw/job_stat.c +++ b/src/bgw/job_stat.c @@ -181,8 +181,8 @@ typedef struct * In those cases, we only have month components. So we compute the difference in * months between the initial_start's timebucket and the finish time's bucket. */ -static TimestampTz -get_next_scheduled_execution_slot(BgwJob *job, TimestampTz finish_time) +TimestampTz +ts_get_next_scheduled_execution_slot(BgwJob *job, TimestampTz finish_time) { Assert(job->fd.fixed_schedule == true); Datum schedint_datum = IntervalPGetDatum(&job->fd.schedule_interval); @@ -278,7 +278,7 @@ calculate_next_start_on_success_fixed(TimestampTz finish_time, BgwJob *job) { TimestampTz next_slot; - next_slot = get_next_scheduled_execution_slot(job, finish_time); + next_slot = ts_get_next_scheduled_execution_slot(job, finish_time); return next_slot; } @@ -431,7 +431,7 @@ calculate_next_start_on_failure(TimestampTz finish_time, int consecutive_failure * of the next scheduled slot, so we don't get off track */ if (job->fd.fixed_schedule) { - TimestampTz next_slot = get_next_scheduled_execution_slot(job, finish_time); + TimestampTz next_slot = ts_get_next_scheduled_execution_slot(job, finish_time); if (res > next_slot) res = next_slot; } diff --git a/src/bgw/job_stat.h b/src/bgw/job_stat.h index 12acf94e44c..77dcbfc77a0 100644 --- a/src/bgw/job_stat.h +++ b/src/bgw/job_stat.h @@ -43,4 +43,6 @@ extern TimestampTz ts_bgw_job_stat_next_start(BgwJobStat *jobstat, BgwJob *job, int32 consecutive_failed_launches); extern TSDLLEXPORT void ts_bgw_job_stat_mark_crash_reported(int32 bgw_job_id); +extern TSDLLEXPORT TimestampTz ts_get_next_scheduled_execution_slot(BgwJob *job, + TimestampTz finish_time); #endif /* BGW_JOB_STAT_H */ diff --git a/test/src/bgw/scheduler_mock.c b/test/src/bgw/scheduler_mock.c index 5263e6b9d7e..99c6f65c7e6 100644 --- a/test/src/bgw/scheduler_mock.c +++ b/test/src/bgw/scheduler_mock.c @@ -58,7 +58,7 @@ static const char *test_job_type_names[_MAX_TEST_JOB_TYPE] = { [TEST_JOB_TYPE_JOB_4] = "bgw_test_job_4", }; -/* this is copied from the job_stat/get_next_scheduled_execution_slot */ +/* this is copied from the job_stat/ts_get_next_scheduled_execution_slot */ extern Datum ts_test_next_scheduled_execution_slot(PG_FUNCTION_ARGS) { diff --git a/tsl/src/bgw_policy/job_api.c b/tsl/src/bgw_policy/job_api.c index 8d87e95837e..5202ec7bb33 100644 --- a/tsl/src/bgw_policy/job_api.c +++ b/tsl/src/bgw_policy/job_api.c @@ -30,7 +30,7 @@ /* Default retry period for reorder_jobs is currently 5 minutes */ #define DEFAULT_RETRY_PERIOD (5 * USECS_PER_MINUTE) -#define ALTER_JOB_NUM_COLS 10 +#define ALTER_JOB_NUM_COLS 13 /* * This function ensures that the check function has the required signature @@ -282,6 +282,9 @@ job_run(PG_FUNCTION_ARGS) * 7 next_start TIMESTAMPTZ = NULL * 8 if_exists BOOL = FALSE, * 9 check_config REGPROC = NULL + * 10 fixed_schedule BOOL = NULL, + * 11 initial_start TIMESTAMPTZ = NULL + * 12 timezone TEXT = NULL * ) RETURNS TABLE ( * job_id INTEGER, * schedule_interval INTERVAL, @@ -292,6 +295,9 @@ job_run(PG_FUNCTION_ARGS) * config JSONB, * next_start TIMESTAMPTZ * check_config TEXT + * fixed_schedule BOOL + * initial_start TIMESTAMPTZ + * timezone TEXT * ) */ Datum @@ -313,6 +319,12 @@ job_alter(PG_FUNCTION_ARGS) /* Added space for period and NULL */ char schema_qualified_check_name[2 * NAMEDATALEN + 2] = { 0 }; bool unregister_check = (!PG_ARGISNULL(9) && !OidIsValid(check)); + TimestampTz initial_start = PG_ARGISNULL(11) ? DT_NOBEGIN : PG_GETARG_TIMESTAMPTZ(11); + text *timezone = PG_ARGISNULL(12) ? NULL : PG_GETARG_TEXT_PP(12); + char *valid_timezone = NULL; + /* verify it's a valid timezone */ + if (timezone != NULL) + valid_timezone = ts_bgw_job_validate_timezone(PG_GETARG_DATUM(12)); TS_PREVENT_FUNC_IF_READ_ONLY(); @@ -387,7 +399,86 @@ job_alter(PG_FUNCTION_ARGS) namestrcpy(&job->fd.check_schema, NameStr(empty_namedata)); namestrcpy(&job->fd.check_name, NameStr(empty_namedata)); } + + if (!PG_ARGISNULL(10)) + { + bool fixed_schedule = PG_GETARG_BOOL(10); + /* + * initial_start is a required argument for fixed schedules + * so we use the current timestamp if it's not provided + */ + if (fixed_schedule) + { + if (TIMESTAMP_NOT_FINITE(initial_start)) + { + initial_start = ts_timer_get_current_timestamp(); + elog(NOTICE, + "Using current time [%s] as initial start for job %d", + DatumGetCString( + DirectFunctionCall1(timestamptz_out, TimestampTzGetDatum(initial_start))), + job->fd.id); + job->fd.initial_start = initial_start; + } + } + job->fd.fixed_schedule = fixed_schedule; + } + if (!PG_ARGISNULL(11)) + { + /* user provided +- infinity as initial_start, this is not acceptable */ + if (TIMESTAMP_NOT_FINITE(initial_start)) + { + initial_start = ts_timer_get_current_timestamp(); + elog(NOTICE, + "Using current time [%s] as initial start for job %d", + DatumGetCString( + DirectFunctionCall1(timestamptz_out, TimestampTzGetDatum(initial_start))), + job->fd.id); + } + job->fd.initial_start = initial_start; + } + + if (valid_timezone != NULL) + job->fd.timezone = cstring_to_text(valid_timezone); + else + job->fd.timezone = NULL; + /* it's also possible to alter the fields initial_start and timezone without + * specifying fixed_schedule. In that case, update them and also update the + * next_start accordingly. + * If the job is not on a fixed schedule, then this has no effect on the next_start, + * so maybe print a message to the user + * that these changes are not really doing anything */ + + /* this function will also update the next_start if the schedule interval is changed, + but I'm not going to rely on this to change stuff */ ts_bgw_job_update_by_id(job_id, job); + /* one of the fields below changing necessitates a next_start update */ + if (!PG_ARGISNULL(10) || !TIMESTAMP_NOT_FINITE(initial_start) || (valid_timezone != NULL)) + { + TimestampTz next_start_calculated; + if (job->fd.fixed_schedule) + { + next_start_calculated = + ts_get_next_scheduled_execution_slot(job, ts_timer_get_current_timestamp()); + ts_bgw_job_stat_update_next_start(job->fd.id, next_start_calculated, false); + } + else + { + /* last finish time plus schedule interval */ + BgwJobStat *stat = ts_bgw_job_stat_find(job->fd.id); + + if (stat != NULL) + { + next_start_calculated = DatumGetTimestampTz( + DirectFunctionCall2(timestamptz_pl_interval, + TimestampTzGetDatum(stat->fd.last_finish), + IntervalPGetDatum(&job->fd.schedule_interval))); + /* allow DT_NOBEGIN for next_start here through allow_unset=true in the case that + * last_finish is DT_NOBEGIN, + * This means the value is counted as unset which is what we want */ + ts_bgw_job_stat_update_next_start(job->fd.id, next_start_calculated, true); + } + } + } if (!PG_ARGISNULL(7)) ts_bgw_job_stat_upsert_next_start(job_id, PG_GETARG_TIMESTAMPTZ(7)); @@ -420,6 +511,21 @@ job_alter(PG_FUNCTION_ARGS) else nulls[8] = true; + /* values/nulls[9]: fixed_schedule */ + values[9] = job->fd.fixed_schedule; + /* values/nulls[10]: initial_start */ + if (TIMESTAMP_NOT_FINITE(job->fd.initial_start)) + { + nulls[10] = true; + } + else + values[10] = TimestampTzGetDatum(job->fd.initial_start); + /* values/nulls[11]: timezone */ + if (valid_timezone) + values[11] = CStringGetTextDatum(valid_timezone); + else + nulls[11] = true; + tuple = heap_form_tuple(tupdesc, values, nulls); return HeapTupleGetDatum(tuple); } diff --git a/tsl/test/expected/bgw_custom.out b/tsl/test/expected/bgw_custom.out index 0227bf5a0af..6ba5bcc306a 100644 --- a/tsl/test/expected/bgw_custom.out +++ b/tsl/test/expected/bgw_custom.out @@ -917,9 +917,9 @@ ALTER TABLE sensor_data SET (timescaledb.compress, timescaledb.compress_orderby SELECT add_compression_policy('sensor_data', INTERVAL '1' minute) AS compressjob_id \gset -- set recompress to true SELECT alter_job(id,config:=jsonb_set(config,'{recompress}', 'true')) FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1014,"@ 3 days 12 hours","@ 0",-1,"@ 1 hour",t,"{""recompress"": true, ""hypertable_id"": 4, ""compress_after"": ""@ 1 min""}",-infinity,_timescaledb_internal.policy_compression_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1014,"@ 3 days 12 hours","@ 0",-1,"@ 1 hour",t,"{""recompress"": true, ""hypertable_id"": 4, ""compress_after"": ""@ 1 min""}",-infinity,_timescaledb_internal.policy_compression_check,f,,) (1 row) -- create new chunks diff --git a/tsl/test/expected/bgw_db_scheduler.out b/tsl/test/expected/bgw_db_scheduler.out index 74b92574128..a9219895b67 100644 --- a/tsl/test/expected/bgw_db_scheduler.out +++ b/tsl/test/expected/bgw_db_scheduler.out @@ -1418,9 +1418,9 @@ SELECT wait_for_timer_to_run(0); SELECT insert_job('another', 'bgw_test_job_1', INTERVAL '100ms', INTERVAL '100s', INTERVAL '1s') AS job_id \gset -- call alter_job to trigger cache invalidation SELECT alter_job(:job_id,scheduled:=true); - alter_job ------------------------------------------------------------------ - (1024,"@ 0.1 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,) + alter_job +--------------------------------------------------------------------- + (1024,"@ 0.1 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,,f,,) (1 row) SELECT ts_bgw_params_reset_time(50000, true); @@ -1534,9 +1534,9 @@ SELECT wait_for_timer_to_run(400000); SELECT insert_job('new_job', 'bgw_test_job_1', INTERVAL '10ms', INTERVAL '100s', INTERVAL '1s') AS job_id \gset -- call alter_job to trigger cache invalidation SELECT alter_job(:job_id,scheduled:=true); - alter_job ------------------------------------------------------------------- - (1025,"@ 0.01 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,) + alter_job +---------------------------------------------------------------------- + (1025,"@ 0.01 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,,f,,) (1 row) SELECT ts_bgw_params_reset_time(450000, true); diff --git a/tsl/test/expected/bgw_db_scheduler_fixed.out b/tsl/test/expected/bgw_db_scheduler_fixed.out index 67c452fe805..36924390e2c 100644 --- a/tsl/test/expected/bgw_db_scheduler_fixed.out +++ b/tsl/test/expected/bgw_db_scheduler_fixed.out @@ -1418,9 +1418,9 @@ SELECT wait_for_timer_to_run(0); SELECT insert_job('another', 'bgw_test_job_1', INTERVAL '100ms', INTERVAL '100s', INTERVAL '1s') AS job_id \gset -- call alter_job to trigger cache invalidation SELECT alter_job(:job_id,scheduled:=true); - alter_job ------------------------------------------------------------------ - (1024,"@ 0.1 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,) + alter_job +--------------------------------------------------------------------------------------------------- + (1024,"@ 0.1 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,,t,"Fri Dec 31 16:00:00 1999 PST",) (1 row) SELECT ts_bgw_params_reset_time(50000, true); @@ -1520,9 +1520,9 @@ SELECT wait_for_timer_to_run(400000); SELECT insert_job('new_job', 'bgw_test_job_1', INTERVAL '10ms', INTERVAL '100s', INTERVAL '1s') AS job_id \gset -- call alter_job to trigger cache invalidation SELECT alter_job(:job_id,scheduled:=true); - alter_job ------------------------------------------------------------------- - (1025,"@ 0.01 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,) + alter_job +---------------------------------------------------------------------------------------------------- + (1025,"@ 0.01 secs","@ 1 min 40 secs",5,"@ 1 sec",t,,-infinity,,t,"Fri Dec 31 16:00:00 1999 PST",) (1 row) SELECT ts_bgw_params_reset_time(450000, true); @@ -1786,3 +1786,121 @@ ORDER BY job_id; 1031 | Fri Dec 31 16:00:00 1999 PST | Fri Dec 31 16:00:00 1999 PST | Sat Jan 15 16:00:00 2000 PST | Fri Dec 31 16:00:00 1999 PST (6 rows) +-- test ability to switch from one type of schedule to another +CREATE OR REPLACE PROCEDURE job_test(jobid int, config jsonb) language plpgsql as $$ +BEGIN +PERFORM pg_sleep(10); +END +$$; +SELECT add_job('job_test', '8 min', fixed_schedule => false) AS jobid_drifting_1 \gset +SELECT add_job('job_test', '8 min', fixed_schedule => false) AS jobid_drifting_2 \gset +SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(25); + ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish +------------------------------------------------------------ + +(1 row) + +SELECT last_finish AS finish_time_drifting_1 FROM _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_drifting_1 \gset +-- job is on fixed schedule, so changing the timezone and initial start, has no effect on its next start, +-- which should be 8 min after the finish time +SELECT next_start AS next_start_drifting_1 FROM alter_job(:jobid_drifting_1, schedule_interval => interval '10 min', timezone => 'Europe/Athens') \gset +SELECT :'next_start_drifting_1'::timestamptz - :'finish_time_drifting_1'::timestamptz as diff_interval; + diff_interval +--------------- + @ 10 mins +(1 row) + +-- this will print a notice about using the current time as initial start +-- suppress the notice though as it will lead to flaky tests +set client_min_messages = 'warning'; +SELECT next_start, initial_start FROM alter_job(:jobid_drifting_1, schedule_interval => interval '10 min', fixed_schedule => true, initial_start => '-infinity') \gset +-- should be 10 min +SELECT :'next_start'::timestamptz - :'initial_start'::timestamptz; + ?column? +----------- + @ 10 mins +(1 row) + +-- if job is not on fixed schedule, and we change it to fixed schedule, then user should also provide initial_start. +-- if they don't, a notice is printed that we're using current time as initial start +SELECT next_start, initial_start FROM alter_job(:jobid_drifting_2, schedule_interval => interval '10 min', fixed_schedule => true) \gset +SELECT :'next_start'::timestamptz - :'initial_start'::timestamptz; + ?column? +----------- + @ 10 mins +(1 row) + +reset client_min_messages; +-- jobs starting with fixed schedules +SELECT add_job('job_test', '1 month', initial_start => '2000-01-01 00:03') as jobid_fixed_1 \gset +-- wait for the job to run, then check its next_start: (3 minutes = 180mil microseconds) +SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(180000005); + ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish +------------------------------------------------------------ + +(1 row) + +SELECT last_finish, next_start from _timescaledb_internal.bgw_job_stat where job_id = :jobid_fixed_1; + last_finish | next_start +------------------------------+------------------------------ + Sat Jan 01 00:03:00 2000 PST | Tue Feb 01 00:03:00 2000 PST +(1 row) + +SELECT date_part('hour',next_start)::integer, date_part('minute',next_start)::integer, date_part('second',next_start)::integer FROM alter_job(:jobid_fixed_1, initial_start => '2020-01-01 04:00'); + date_part | date_part | date_part +-----------+-----------+----------- + 4 | 0 | 0 +(1 row) + +SELECT date_part('hour',next_start)::integer, date_part('minute',next_start)::integer, date_part('second',next_start)::integer FROM _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_fixed_1; + date_part | date_part | date_part +-----------+-----------+----------- + 4 | 0 | 0 +(1 row) + +-- go from fixed_schedule to drifting schedule +SELECT ts_bgw_params_destroy(); + ts_bgw_params_destroy +----------------------- + +(1 row) + +SELECT ts_bgw_params_create(); + ts_bgw_params_create +---------------------- + +(1 row) + +SELECT add_job('job_test', '30 sec', initial_start => '2000-01-01 00:00:23') as jobid_fixed_2 \gset +-- wait for the job to run, check the next_start, once it's finished, switch to drifting schedule and +-- check the next_start again +-- wait for 30 seconds to pass +SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(30000025); + ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish +------------------------------------------------------------ + +(1 row) + +select * from _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_fixed_2; + job_id | last_start | last_finish | next_start | last_successful_finish | last_run_success | total_runs | total_duration | total_duration_failures | total_successes | total_failures | total_crashes | consecutive_failures | consecutive_crashes | flags +--------+------------------------------+------------------------------+------------------------------+------------------------------+------------------+------------+----------------+-------------------------+-----------------+----------------+---------------+----------------------+---------------------+------- + 1035 | Sat Jan 01 00:00:23 2000 PST | Sat Jan 01 00:00:23 2000 PST | Sat Jan 01 00:00:53 2000 PST | Sat Jan 01 00:00:23 2000 PST | t | 1 | @ 0 | @ 0 | 1 | 0 | 0 | 0 | 0 | 0 +(1 row) + +UPDATE _timescaledb_internal.bgw_job_stat +SET last_finish = last_finish + interval '10 sec', last_successful_finish = last_successful_finish + interval '10 sec' +WHERE job_id = :jobid_fixed_2; +-- next_start is unchanged +SELECT * FROM _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_fixed_2; + job_id | last_start | last_finish | next_start | last_successful_finish | last_run_success | total_runs | total_duration | total_duration_failures | total_successes | total_failures | total_crashes | consecutive_failures | consecutive_crashes | flags +--------+------------------------------+------------------------------+------------------------------+------------------------------+------------------+------------+----------------+-------------------------+-----------------+----------------+---------------+----------------------+---------------------+------- + 1035 | Sat Jan 01 00:00:23 2000 PST | Sat Jan 01 00:00:33 2000 PST | Sat Jan 01 00:00:53 2000 PST | Sat Jan 01 00:00:33 2000 PST | t | 1 | @ 0 | @ 0 | 1 | 0 | 0 | 0 | 0 | 0 +(1 row) + +-- next start is now updated +SELECT alter_job(:jobid_fixed_2, fixed_schedule => false); + alter_job +------------------------------------------------------------------------------------------------------------- + (1035,"@ 30 secs","@ 0",-1,"@ 5 mins",t,,"Sat Jan 01 00:01:03 2000 PST",,f,"Sat Jan 01 00:00:23 2000 PST",) +(1 row) + diff --git a/tsl/test/expected/bgw_reorder_drop_chunks.out b/tsl/test/expected/bgw_reorder_drop_chunks.out index 736bc7411ed..a3fea4b6d2a 100644 --- a/tsl/test/expected/bgw_reorder_drop_chunks.out +++ b/tsl/test/expected/bgw_reorder_drop_chunks.out @@ -409,9 +409,9 @@ SELECT count(*) FROM _timescaledb_config.bgw_job WHERE proc_schema = '_timescale (1 row) SELECT alter_job(:drop_chunks_job_id, schedule_interval => INTERVAL '1 second'); - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 1 sec","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""hypertable_id"": 2}",-infinity,_timescaledb_internal.policy_retention_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 sec","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""hypertable_id"": 2}",-infinity,_timescaledb_internal.policy_retention_check,f,,) (1 row) SELECT * FROM timescaledb_information.jobs WHERE job_id=:drop_chunks_job_id; @@ -622,16 +622,16 @@ SELECT add_retention_policy('test_drop_chunks_table_tsntz', INTERVAL '4 months') -- Test that retention policy is being logged SELECT alter_job(id,config:=jsonb_set(config,'{verbose_log}', 'true')) FROM _timescaledb_config.bgw_job WHERE id = :drop_chunks_date_job_id; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 1 day","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""verbose_log"": true, ""hypertable_id"": 3}",-infinity,_timescaledb_internal.policy_retention_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 1 day","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""verbose_log"": true, ""hypertable_id"": 3}",-infinity,_timescaledb_internal.policy_retention_check,f,,) (1 row) SELECT alter_job(id,config:=jsonb_set(config,'{verbose_log}', 'true')) FROM _timescaledb_config.bgw_job WHERE id = :drop_chunks_tsntz_job_id; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1003,"@ 1 day","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""verbose_log"": true, ""hypertable_id"": 4}",-infinity,_timescaledb_internal.policy_retention_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1003,"@ 1 day","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""verbose_log"": true, ""hypertable_id"": 4}",-infinity,_timescaledb_internal.policy_retention_check,f,,) (1 row) CALL run_job(:drop_chunks_date_job_id); diff --git a/tsl/test/expected/cagg_bgw.out b/tsl/test/expected/cagg_bgw.out index 513f7c86c4b..c2250ec0513 100644 --- a/tsl/test/expected/cagg_bgw.out +++ b/tsl/test/expected/cagg_bgw.out @@ -272,9 +272,9 @@ SELECT ts_bgw_params_reset_time((extract(epoch from interval '12 hour')::bigint --alter the refresh interval and check if next_start is altered SELECT alter_job(:job_id, schedule_interval => '1m', retry_period => '1m'); - alter_job --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:01:00 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:01:00 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT job_id, next_start - last_finish as until_next, total_runs @@ -312,9 +312,9 @@ SELECT (next_start - '30s'::interval) AS "NEW_NEXT_START" FROM _timescaledb_internal.bgw_job_stat WHERE job_id=:job_id \gset SELECT alter_job(:job_id, next_start => :'NEW_NEXT_START'); - alter_job --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:02:30 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:02:30 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT ts_bgw_params_reset_time((extract(epoch from interval '12 hour')::bigint * 1000000)+(extract(epoch from interval '2 minute 30 seconds')::bigint * 1000000), true); diff --git a/tsl/test/expected/cagg_bgw_dist_ht.out b/tsl/test/expected/cagg_bgw_dist_ht.out index 1526b67a2f2..b1b2186441f 100644 --- a/tsl/test/expected/cagg_bgw_dist_ht.out +++ b/tsl/test/expected/cagg_bgw_dist_ht.out @@ -309,9 +309,9 @@ SELECT ts_bgw_params_reset_time((extract(epoch from interval '12 hour')::bigint --alter the refresh interval and check if next_start is altered SELECT alter_job(:job_id, schedule_interval => '1m', retry_period => '1m'); - alter_job --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:01:00 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:01:00 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT job_id, next_start - last_finish as until_next, total_runs @@ -349,9 +349,9 @@ SELECT (next_start - '30s'::interval) AS "NEW_NEXT_START" FROM _timescaledb_internal.bgw_job_stat WHERE job_id=:job_id \gset SELECT alter_job(:job_id, next_start => :'NEW_NEXT_START'); - alter_job --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:02:30 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + (1000,"@ 1 min","@ 0",-1,"@ 1 min",t,"{""end_offset"": 4, ""start_offset"": null, ""mat_hypertable_id"": 2}","Sat Jan 01 04:02:30 2000 PST",_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT ts_bgw_params_reset_time((extract(epoch from interval '12 hour')::bigint * 1000000)+(extract(epoch from interval '2 minute 30 seconds')::bigint * 1000000), true); diff --git a/tsl/test/expected/cagg_bgw_drop_chunks.out b/tsl/test/expected/cagg_bgw_drop_chunks.out index d0d349ed9f4..79b629e5b2a 100644 --- a/tsl/test/expected/cagg_bgw_drop_chunks.out +++ b/tsl/test/expected/cagg_bgw_drop_chunks.out @@ -97,9 +97,9 @@ WHERE hypertable_name = '_materialized_hypertable_2' ORDER BY range_start_intege SELECT add_retention_policy( 'drop_chunks_view1', drop_after => 10) as drop_chunks_job_id1 \gset SELECT alter_job(:drop_chunks_job_id1, schedule_interval => INTERVAL '1 second'); - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 sec","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": 10, ""hypertable_id"": 2}",-infinity,_timescaledb_internal.policy_retention_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------- + (1000,"@ 1 sec","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": 10, ""hypertable_id"": 2}",-infinity,_timescaledb_internal.policy_retention_check,f,,) (1 row) SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(2000000); diff --git a/tsl/test/expected/cagg_usage.out b/tsl/test/expected/cagg_usage.out index 48c43ac064c..beaf1314227 100644 --- a/tsl/test/expected/cagg_usage.out +++ b/tsl/test/expected/cagg_usage.out @@ -101,9 +101,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job WHERE id = 1000; -- You can change this setting with ALTER VIEW (equivalently, specify in WITH clause of CREATE VIEW) SELECT alter_job(1000, schedule_interval := '1h'); - alter_job --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 hour","@ 0",-1,"@ 2 hours",t,"{""end_offset"": ""@ 2 hours"", ""start_offset"": null, ""mat_hypertable_id"": 2}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + (1000,"@ 1 hour","@ 0",-1,"@ 2 hours",t,"{""end_offset"": ""@ 2 hours"", ""start_offset"": null, ""mat_hypertable_id"": 2}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job WHERE id = 1000; diff --git a/tsl/test/expected/compress_bgw_reorder_drop_chunks.out b/tsl/test/expected/compress_bgw_reorder_drop_chunks.out index 41a14c35f5b..a7b114b9f45 100644 --- a/tsl/test/expected/compress_bgw_reorder_drop_chunks.out +++ b/tsl/test/expected/compress_bgw_reorder_drop_chunks.out @@ -81,9 +81,9 @@ SELECT count(*) FROM _timescaledb_config.bgw_job WHERE proc_schema = '_timescale (1 row) SELECT alter_job(:retention_job_id, schedule_interval => INTERVAL '1 second'); - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1000,"@ 1 sec","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""hypertable_id"": 1}",-infinity,_timescaledb_internal.policy_retention_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1000,"@ 1 sec","@ 5 mins",-1,"@ 5 mins",t,"{""drop_after"": ""@ 4 mons"", ""hypertable_id"": 1}",-infinity,_timescaledb_internal.policy_retention_check,f,,) (1 row) SELECT * FROM _timescaledb_config.bgw_job where id=:retention_job_id; diff --git a/tsl/test/expected/compression_bgw.out b/tsl/test/expected/compression_bgw.out index 0c10bb7f71e..cd3a969deac 100644 --- a/tsl/test/expected/compression_bgw.out +++ b/tsl/test/expected/compression_bgw.out @@ -40,17 +40,17 @@ select * from _timescaledb_config.bgw_job where id = :compressjob_id; (1 row) select * from alter_job(:compressjob_id, schedule_interval=>'1s'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------+------------+------------------------------------------------ - 1000 | @ 1 sec | @ 0 | -1 | @ 1 hour | t | {"hypertable_id": 1, "compress_after": "@ 60 days"} | -infinity | _timescaledb_internal.policy_compression_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------+------------+------------------------------------------------+----------------+---------------+---------- + 1000 | @ 1 sec | @ 0 | -1 | @ 1 hour | t | {"hypertable_id": 1, "compress_after": "@ 60 days"} | -infinity | _timescaledb_internal.policy_compression_check | f | | (1 row) --enable maxchunks to 1 so that only 1 chunk is compressed by the job SELECT alter_job(id,config:=jsonb_set(config,'{maxchunks_to_compress}', '1')) FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 sec","@ 0",-1,"@ 1 hour",t,"{""hypertable_id"": 1, ""compress_after"": ""@ 60 days"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1000,"@ 1 sec","@ 0",-1,"@ 1 hour",t,"{""hypertable_id"": 1, ""compress_after"": ""@ 60 days"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check,f,,) (1 row) select * from _timescaledb_config.bgw_job where id >= 1000 ORDER BY id; @@ -330,16 +330,16 @@ SELECT add_compression_policy AS job_id -- job compresses only 1 chunk at a time -- SELECT alter_job(id,config:=jsonb_set(config,'{maxchunks_to_compress}', '1')) FROM _timescaledb_config.bgw_job WHERE id = :job_id; - alter_job ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1004,"@ 12 hours","@ 0",-1,"@ 1 hour",t,"{""hypertable_id"": 11, ""compress_after"": ""@ 1 day"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check) + alter_job +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1004,"@ 12 hours","@ 0",-1,"@ 1 hour",t,"{""hypertable_id"": 11, ""compress_after"": ""@ 1 day"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check,f,,) (1 row) SELECT alter_job(id,config:=jsonb_set(config,'{verbose_log}', 'true')) FROM _timescaledb_config.bgw_job WHERE id = :job_id; - alter_job --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1004,"@ 12 hours","@ 0",-1,"@ 1 hour",t,"{""verbose_log"": true, ""hypertable_id"": 11, ""compress_after"": ""@ 1 day"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check) + alter_job +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + (1004,"@ 12 hours","@ 0",-1,"@ 1 hour",t,"{""verbose_log"": true, ""hypertable_id"": 11, ""compress_after"": ""@ 1 day"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check,f,,) (1 row) set client_min_messages TO LOG; @@ -524,7 +524,7 @@ ALTER TABLE metrics SET (timescaledb.compress); -- create chunk with some data and compress INSERT INTO metrics SELECT '2000-01-01' FROM generate_series(1,10); -- create custom compression job without recompress boolean -SELECT add_job('_timescaledb_internal.policy_compression','1w',('{"hypertable_id": '||:'HYPERTABLE_ID'||', "compress_after": "@ 7 days"}')::jsonb) AS "JOB_COMPRESS" \gset +SELECT add_job('_timescaledb_internal.policy_compression','1w',('{"hypertable_id": '||:'HYPERTABLE_ID'||', "compress_after": "@ 7 days"}')::jsonb, initial_start => '2000-01-01 00:00:00+00'::timestamptz) AS "JOB_COMPRESS" \gset -- first call should compress CALL run_job(:JOB_COMPRESS); -- 2nd call should do nothing @@ -556,9 +556,9 @@ SELECT chunk_status FROM compressed_chunk_info_view WHERE hypertable_name = 'met -- disable recompress in compress job SELECT alter_job(id,config:=jsonb_set(config,'{recompress}','false'), next_start => '2000-01-01 00:00:00+00'::timestamptz) FROM _timescaledb_config.bgw_job WHERE id = :JOB_COMPRESS; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1006,"@ 7 days","@ 0",-1,"@ 5 mins",t,"{""recompress"": false, ""hypertable_id"": 16, ""compress_after"": ""@ 7 days""}","Fri Dec 31 16:00:00 1999 PST",) + alter_job +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1006,"@ 7 days","@ 0",-1,"@ 5 mins",t,"{""recompress"": false, ""hypertable_id"": 16, ""compress_after"": ""@ 7 days""}","Fri Dec 31 16:00:00 1999 PST",,t,"Fri Dec 31 16:00:00 1999 PST",) (1 row) -- nothing to do @@ -590,9 +590,9 @@ SELECT chunk_status FROM compressed_chunk_info_view WHERE hypertable_name = 'met -- reenable recompress in compress job SELECT alter_job(id,config:=jsonb_set(config,'{recompress}','true'), next_start => '2000-01-01 00:00:00+00'::timestamptz) FROM _timescaledb_config.bgw_job WHERE id = :JOB_COMPRESS; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1006,"@ 7 days","@ 0",-1,"@ 5 mins",t,"{""recompress"": true, ""hypertable_id"": 16, ""compress_after"": ""@ 7 days""}","Fri Dec 31 16:00:00 1999 PST",) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1006,"@ 7 days","@ 0",-1,"@ 5 mins",t,"{""recompress"": true, ""hypertable_id"": 16, ""compress_after"": ""@ 7 days""}","Fri Dec 31 16:00:00 1999 PST",,t,"Fri Dec 31 16:00:00 1999 PST",) (1 row) -- should recompress now diff --git a/tsl/test/expected/continuous_aggs-12.out b/tsl/test/expected/continuous_aggs-12.out index b5485eef196..74cd13af2cc 100644 --- a/tsl/test/expected/continuous_aggs-12.out +++ b/tsl/test/expected/continuous_aggs-12.out @@ -855,9 +855,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -867,9 +867,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -948,9 +948,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/continuous_aggs-13.out b/tsl/test/expected/continuous_aggs-13.out index b5485eef196..74cd13af2cc 100644 --- a/tsl/test/expected/continuous_aggs-13.out +++ b/tsl/test/expected/continuous_aggs-13.out @@ -855,9 +855,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -867,9 +867,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -948,9 +948,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/continuous_aggs-14.out b/tsl/test/expected/continuous_aggs-14.out index 4975fc0a8d9..20722cfb9c9 100644 --- a/tsl/test/expected/continuous_aggs-14.out +++ b/tsl/test/expected/continuous_aggs-14.out @@ -855,9 +855,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -867,9 +867,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -948,9 +948,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/continuous_aggs-15.out b/tsl/test/expected/continuous_aggs-15.out index c42f528ad73..e538126d019 100644 --- a/tsl/test/expected/continuous_aggs-15.out +++ b/tsl/test/expected/continuous_aggs-15.out @@ -855,9 +855,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -867,9 +867,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -948,9 +948,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/continuous_aggs_deprecated-12.out b/tsl/test/expected/continuous_aggs_deprecated-12.out index 89943f00bd8..a9c00d3cdd0 100644 --- a/tsl/test/expected/continuous_aggs_deprecated-12.out +++ b/tsl/test/expected/continuous_aggs_deprecated-12.out @@ -869,9 +869,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -881,9 +881,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -967,9 +967,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/continuous_aggs_deprecated-13.out b/tsl/test/expected/continuous_aggs_deprecated-13.out index 89943f00bd8..a9c00d3cdd0 100644 --- a/tsl/test/expected/continuous_aggs_deprecated-13.out +++ b/tsl/test/expected/continuous_aggs_deprecated-13.out @@ -869,9 +869,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -881,9 +881,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -967,9 +967,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/continuous_aggs_deprecated-14.out b/tsl/test/expected/continuous_aggs_deprecated-14.out index bb5f7b4b0ad..b9ee54b1111 100644 --- a/tsl/test/expected/continuous_aggs_deprecated-14.out +++ b/tsl/test/expected/continuous_aggs_deprecated-14.out @@ -869,9 +869,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -881,9 +881,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -967,9 +967,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/continuous_aggs_deprecated-15.out b/tsl/test/expected/continuous_aggs_deprecated-15.out index bb5f7b4b0ad..b9ee54b1111 100644 --- a/tsl/test/expected/continuous_aggs_deprecated-15.out +++ b/tsl/test/expected/continuous_aggs_deprecated-15.out @@ -869,9 +869,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, '5 h'::interval, ' (1 row) SELECT alter_job(id, schedule_interval => '1h') FROM _timescaledb_config.bgw_job; - alter_job ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 1 hour","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -881,9 +881,9 @@ SELECT schedule_interval FROM _timescaledb_config.bgw_job; (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1001,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": ""@ 5 hours"", ""start_offset"": null, ""mat_hypertable_id"": 20}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; @@ -967,9 +967,9 @@ SELECT add_continuous_aggregate_policy('mat_with_test', NULL, 500::integer, '12 (1 row) SELECT alter_job(id, schedule_interval => '2h') FROM _timescaledb_config.bgw_job; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1002,"@ 2 hours","@ 0",-1,"@ 12 hours",t,"{""end_offset"": 500, ""start_offset"": null, ""mat_hypertable_id"": 23}",-infinity,_timescaledb_internal.policy_refresh_continuous_aggregate_check,f,,) (1 row) SELECT schedule_interval FROM _timescaledb_config.bgw_job; diff --git a/tsl/test/expected/dist_compression.out b/tsl/test/expected/dist_compression.out index e103e1efa3b..81db1105b4e 100644 --- a/tsl/test/expected/dist_compression.out +++ b/tsl/test/expected/dist_compression.out @@ -665,9 +665,9 @@ select * from _timescaledb_config.bgw_job where id = :compressjob_id; (1 row) select * from alter_job(:compressjob_id, schedule_interval=>'1s'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------+------------+------------------------------------------------ - 1000 | @ 1 sec | @ 0 | -1 | @ 1 hour | t | {"hypertable_id": 2, "compress_after": "@ 60 days"} | -infinity | _timescaledb_internal.policy_compression_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------+------------+------------------------------------------------+----------------+---------------+---------- + 1000 | @ 1 sec | @ 0 | -1 | @ 1 hour | t | {"hypertable_id": 2, "compress_after": "@ 60 days"} | -infinity | _timescaledb_internal.policy_compression_check | f | | (1 row) select * from _timescaledb_config.bgw_job where id >= 1000 ORDER BY id; @@ -679,9 +679,9 @@ select * from _timescaledb_config.bgw_job where id >= 1000 ORDER BY id; -- we want only 1 chunk to be compressed -- SELECT alter_job(id,config:=jsonb_set(config,'{maxchunks_to_compress}', '1')) FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - alter_job -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (1000,"@ 1 sec","@ 0",-1,"@ 1 hour",t,"{""hypertable_id"": 2, ""compress_after"": ""@ 60 days"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check) + alter_job +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + (1000,"@ 1 sec","@ 0",-1,"@ 1 hour",t,"{""hypertable_id"": 2, ""compress_after"": ""@ 60 days"", ""maxchunks_to_compress"": 1}",-infinity,_timescaledb_internal.policy_compression_check,f,,) (1 row) insert into conditions diff --git a/tsl/test/expected/tsl_tables.out b/tsl/test/expected/tsl_tables.out index 358e0be94fe..0a8bc6c3a97 100644 --- a/tsl/test/expected/tsl_tables.out +++ b/tsl/test/expected/tsl_tables.out @@ -626,72 +626,72 @@ select add_reorder_policy('test_table', 'test_table_time_idx') as job_id \gset -- No change select * from alter_job(:job_id); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 84 hours | @ 0 | -1 | @ 5 mins | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 84 hours | @ 0 | -1 | @ 5 mins | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) -- Changes expected select * from alter_job(:job_id, INTERVAL '3 years', INTERVAL '5 min', 5, INTERVAL '123 sec'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+-------------+-------------+-----------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 3 years | @ 5 mins | 5 | @ 2 mins 3 secs | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+-------------+-------------+-----------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 3 years | @ 5 mins | 5 | @ 2 mins 3 secs | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select * from alter_job(:job_id, INTERVAL '123 years'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+-------------+-------------+-----------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 5 mins | 5 | @ 2 mins 3 secs | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+-------------+-------------+-----------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 5 mins | 5 | @ 2 mins 3 secs | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select * from alter_job(:job_id, retry_period => INTERVAL '33 hours'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 5 mins | 5 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+-------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 5 mins | 5 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select * from alter_job(:job_id, max_runtime => INTERVAL '456 sec'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 7 mins 36 secs | 5 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 7 mins 36 secs | 5 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select * from alter_job(:job_id, max_retries => 0); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 7 mins 36 secs | 0 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 7 mins 36 secs | 0 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select * from alter_job(:job_id, max_retries => -1); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 7 mins 36 secs | -1 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 7 mins 36 secs | -1 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select * from alter_job(:job_id, max_retries => 20); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) -- No change select * from alter_job(:job_id, max_runtime => NULL); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select * from alter_job(:job_id, max_retries => NULL); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 123 years | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) --change schedule_interval when bgw_job_stat does not exist select * from alter_job(:job_id, schedule_interval=>'1 min'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 1 min | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 1 min | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) select count(*) = 0 from _timescaledb_internal.bgw_job_stat where job_id = :job_id; @@ -702,23 +702,23 @@ select count(*) = 0 from _timescaledb_internal.bgw_job_stat where job_id = :job_ --set next_start when bgw_job_stat does not exist select * from alter_job(:job_id, next_start=>'2001-01-01 01:01:01'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+-------------------------------------------- - 1014 | @ 1 min | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Mon Jan 01 01:01:01 2001 PST | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 1 min | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Mon Jan 01 01:01:01 2001 PST | _timescaledb_internal.policy_reorder_check | f | | (1 row) --change schedule_interval when no last_finish set select * from alter_job(:job_id, schedule_interval=>'10 min'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 10 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 10 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | -infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) --next_start overrides any schedule_interval changes select * from alter_job(:job_id, schedule_interval=>'20 min', next_start=>'2002-01-01 01:01:01'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+-------------------------------------------- - 1014 | @ 20 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Tue Jan 01 01:01:01 2002 PST | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 20 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Tue Jan 01 01:01:01 2002 PST | _timescaledb_internal.policy_reorder_check | f | | (1 row) --set the last_finish manually @@ -727,30 +727,30 @@ UPDATE _timescaledb_internal.bgw_job_stat SET last_finish = '2003-01-01:01:01:01 \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER --not changing the interval doesn't change the next_start select * from alter_job(:job_id, schedule_interval=>'20 min'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+-------------------------------------------- - 1014 | @ 20 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Tue Jan 01 01:01:01 2002 PST | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 20 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Tue Jan 01 01:01:01 2002 PST | _timescaledb_internal.policy_reorder_check | f | | (1 row) --changing the interval changes next_start select * from alter_job(:job_id, schedule_interval=>'30 min'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+-------------------------------------------- - 1014 | @ 30 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Wed Jan 01 01:31:01 2003 PST | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 30 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Wed Jan 01 01:31:01 2003 PST | _timescaledb_internal.policy_reorder_check | f | | (1 row) --explicit next start overrides. select * from alter_job(:job_id, schedule_interval=>'40 min', next_start=>'2004-01-01 01:01:01'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+-------------------------------------------- - 1014 | @ 40 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Thu Jan 01 01:01:01 2004 PST | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------------------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 40 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | Thu Jan 01 01:01:01 2004 PST | _timescaledb_internal.policy_reorder_check | f | | (1 row) --test pausing select * from alter_job(:job_id, next_start=>'infinity'); - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+-------------------------------------------- - 1014 | @ 40 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | infinity | _timescaledb_internal.policy_reorder_check + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+------------------+-------------+--------------+-----------+-----------------------------------------------------------+------------+--------------------------------------------+----------------+---------------+---------- + 1014 | @ 40 mins | @ 7 mins 36 secs | 20 | @ 33 hours | t | {"index_name": "test_table_time_idx", "hypertable_id": 7} | infinity | _timescaledb_internal.policy_reorder_check | f | | (1 row) --test that you can use now() to unpause @@ -805,9 +805,9 @@ ERROR: configuration hypertable id 47 not found -- Check if_exists boolean works correctly select * from alter_job(1234, if_exists => TRUE); NOTICE: job 1234 not found, skipping - job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config ---------+-------------------+-------------+-------------+--------------+-----------+--------+------------+-------------- - | | | | | | | | + job_id | schedule_interval | max_runtime | max_retries | retry_period | scheduled | config | next_start | check_config | fixed_schedule | initial_start | timezone +--------+-------------------+-------------+-------------+--------------+-----------+--------+------------+--------------+----------------+---------------+---------- + | | | | | | | | | | | (1 row) \set ON_ERROR_STOP 0 diff --git a/tsl/test/shared/expected/extension.out b/tsl/test/shared/expected/extension.out index ae07417e3ad..34b385fdd30 100644 --- a/tsl/test/shared/expected/extension.out +++ b/tsl/test/shared/expected/extension.out @@ -154,7 +154,7 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text add_reorder_policy(regclass,name,boolean,timestamp with time zone,text) add_retention_policy(regclass,"any",boolean,interval,timestamp with time zone,text) alter_data_node(name,text,name,integer,boolean) - alter_job(integer,interval,interval,integer,interval,boolean,jsonb,timestamp with time zone,boolean,regproc) + alter_job(integer,interval,interval,integer,interval,boolean,jsonb,timestamp with time zone,boolean,regproc,boolean,timestamp with time zone,text) approximate_row_count(regclass) attach_data_node(name,regclass,boolean,boolean) attach_tablespace(name,regclass,boolean) diff --git a/tsl/test/sql/bgw_db_scheduler_fixed.sql b/tsl/test/sql/bgw_db_scheduler_fixed.sql index f320558f581..9a7c3621a25 100644 --- a/tsl/test/sql/bgw_db_scheduler_fixed.sql +++ b/tsl/test/sql/bgw_db_scheduler_fixed.sql @@ -759,4 +759,57 @@ SELECT FROM _timescaledb_internal.bgw_job_stat ORDER BY job_id; +-- test ability to switch from one type of schedule to another +CREATE OR REPLACE PROCEDURE job_test(jobid int, config jsonb) language plpgsql as $$ +BEGIN +PERFORM pg_sleep(10); +END +$$; +SELECT add_job('job_test', '8 min', fixed_schedule => false) AS jobid_drifting_1 \gset +SELECT add_job('job_test', '8 min', fixed_schedule => false) AS jobid_drifting_2 \gset +SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(25); +SELECT last_finish AS finish_time_drifting_1 FROM _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_drifting_1 \gset +-- job is on fixed schedule, so changing the timezone and initial start, has no effect on its next start, +-- which should be 8 min after the finish time +SELECT next_start AS next_start_drifting_1 FROM alter_job(:jobid_drifting_1, schedule_interval => interval '10 min', timezone => 'Europe/Athens') \gset +SELECT :'next_start_drifting_1'::timestamptz - :'finish_time_drifting_1'::timestamptz as diff_interval; + +-- this will print a notice about using the current time as initial start +-- suppress the notice though as it will lead to flaky tests +set client_min_messages = 'warning'; +SELECT next_start, initial_start FROM alter_job(:jobid_drifting_1, schedule_interval => interval '10 min', fixed_schedule => true, initial_start => '-infinity') \gset +-- should be 10 min +SELECT :'next_start'::timestamptz - :'initial_start'::timestamptz; + +-- if job is not on fixed schedule, and we change it to fixed schedule, then user should also provide initial_start. +-- if they don't, a notice is printed that we're using current time as initial start +SELECT next_start, initial_start FROM alter_job(:jobid_drifting_2, schedule_interval => interval '10 min', fixed_schedule => true) \gset +SELECT :'next_start'::timestamptz - :'initial_start'::timestamptz; + +reset client_min_messages; + +-- jobs starting with fixed schedules +SELECT add_job('job_test', '1 month', initial_start => '2000-01-01 00:03') as jobid_fixed_1 \gset +-- wait for the job to run, then check its next_start: (3 minutes = 180mil microseconds) +SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(180000005); +SELECT last_finish, next_start from _timescaledb_internal.bgw_job_stat where job_id = :jobid_fixed_1; +SELECT date_part('hour',next_start)::integer, date_part('minute',next_start)::integer, date_part('second',next_start)::integer FROM alter_job(:jobid_fixed_1, initial_start => '2020-01-01 04:00'); +SELECT date_part('hour',next_start)::integer, date_part('minute',next_start)::integer, date_part('second',next_start)::integer FROM _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_fixed_1; +-- go from fixed_schedule to drifting schedule +SELECT ts_bgw_params_destroy(); +SELECT ts_bgw_params_create(); +SELECT add_job('job_test', '30 sec', initial_start => '2000-01-01 00:00:23') as jobid_fixed_2 \gset +-- wait for the job to run, check the next_start, once it's finished, switch to drifting schedule and +-- check the next_start again +-- wait for 30 seconds to pass +SELECT ts_bgw_db_scheduler_test_run_and_wait_for_scheduler_finish(30000025); + +select * from _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_fixed_2; +UPDATE _timescaledb_internal.bgw_job_stat +SET last_finish = last_finish + interval '10 sec', last_successful_finish = last_successful_finish + interval '10 sec' +WHERE job_id = :jobid_fixed_2; +-- next_start is unchanged +SELECT * FROM _timescaledb_internal.bgw_job_stat WHERE job_id = :jobid_fixed_2; +-- next start is now updated +SELECT alter_job(:jobid_fixed_2, fixed_schedule => false); diff --git a/tsl/test/sql/include/recompress_basic.sql b/tsl/test/sql/include/recompress_basic.sql index 5a3e4a3576b..eaa1a1f1762 100644 --- a/tsl/test/sql/include/recompress_basic.sql +++ b/tsl/test/sql/include/recompress_basic.sql @@ -126,7 +126,7 @@ ALTER TABLE metrics SET (timescaledb.compress); INSERT INTO metrics SELECT '2000-01-01' FROM generate_series(1,10); -- create custom compression job without recompress boolean -SELECT add_job('_timescaledb_internal.policy_compression','1w',('{"hypertable_id": '||:'HYPERTABLE_ID'||', "compress_after": "@ 7 days"}')::jsonb) AS "JOB_COMPRESS" \gset +SELECT add_job('_timescaledb_internal.policy_compression','1w',('{"hypertable_id": '||:'HYPERTABLE_ID'||', "compress_after": "@ 7 days"}')::jsonb, initial_start => '2000-01-01 00:00:00+00'::timestamptz) AS "JOB_COMPRESS" \gset -- first call should compress CALL run_job(:JOB_COMPRESS);