From 8feec039dc7194c1d5b949a1d6887ff0d1836552 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Fri, 3 Jun 2022 13:33:42 +0200 Subject: [PATCH] Use new validation functions Old patch was using old validation functions, but there are already validation functions that both read and validate the policy, so using those. Also removing the old `job_config_check` function since that is no longer use and instead adding a `job_config_check` that calls the checking function with the configuration. --- src/bgw/job.c | 77 ++++++----- src/bgw/job.h | 7 +- src/cross_module_fn.c | 8 -- src/cross_module_fn.h | 1 - tsl/src/bgw_policy/compression_api.c | 6 +- tsl/src/bgw_policy/continuous_aggregate_api.c | 2 +- tsl/src/bgw_policy/job.c | 104 +-------------- tsl/src/bgw_policy/job.h | 6 - tsl/src/bgw_policy/job_api.c | 5 +- tsl/src/bgw_policy/reorder_api.c | 2 +- tsl/src/bgw_policy/retention_api.c | 2 +- tsl/src/init.c | 1 - tsl/test/expected/bgw_db_scheduler.out | 12 +- tsl/test/expected/bgw_policy.out | 6 +- tsl/test/expected/bgw_reorder_drop_chunks.out | 4 +- tsl/test/expected/cagg_bgw.out | 16 +-- tsl/test/expected/cagg_bgw_dist_ht.out | 16 +-- tsl/test/expected/cagg_errors.out | 5 + tsl/test/expected/cagg_errors_deprecated.out | 5 + .../compress_bgw_reorder_drop_chunks.out | 6 +- tsl/test/expected/compression_bgw.out | 30 ++--- tsl/test/expected/continuous_aggs.out | 18 +-- .../expected/continuous_aggs_deprecated.out | 18 +-- tsl/test/expected/dist_compression.out | 30 ++--- tsl/test/expected/tsl_tables.out | 126 +++++++++--------- tsl/test/sql/cagg_errors.sql | 3 + tsl/test/sql/cagg_errors_deprecated.sql | 3 + 27 files changed, 216 insertions(+), 303 deletions(-) diff --git a/src/bgw/job.c b/src/bgw/job.c index 5ed04e09b67..ab1cb959911 100644 --- a/src/bgw/job.c +++ b/src/bgw/job.c @@ -100,16 +100,49 @@ job_execute_procedure(FuncExpr *funcexpr) ExecuteCallStmt(call, params, false, dest); } +/** + * Run configuration check validation function. + * + * This will run the configuration check validation function registered for + * the job. If a new job is added, the job_id is going to be zero. + */ +void +ts_bgw_job_run_config_check(Oid check, int32 job_id, Jsonb *config) +{ + List *args = + list_make2(makeConst(INT4OID, -1, InvalidOid, 4, Int32GetDatum(job_id), false, true), + makeConst(JSONBOID, -1, InvalidOid, -1, JsonbPGetDatum(config), false, false)); + FuncExpr *funcexpr = + makeFuncExpr(check, VOIDOID, args, InvalidOid, InvalidOid, COERCE_EXPLICIT_CALL); + + /* Nothing to check if there is no check function provided */ + if (!OidIsValid(check)) + return; + + switch (get_func_prokind(check)) + { + case PROKIND_FUNCTION: + job_execute_function(funcexpr); + break; + case PROKIND_PROCEDURE: + job_execute_procedure(funcexpr); + break; + default: + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("unsupported function type"))); + break; + } +} + /* Run the check function on a configuration. It will generate errors if there * is anything wrong with the configuration, otherwise just return. If the * check function does not exist, no checking will be done.*/ static void -job_config_check_mats(BgwJob *job, Jsonb *config) +job_config_check(BgwJob *job, Jsonb *config) { const Oid proc_args[] = { INT4OID, JSONBOID }; - List *name, *args; + List *name; Oid proc; - FuncExpr *funcexpr; bool started = false; /* Both should either be empty or contain a schema and name */ @@ -131,24 +164,7 @@ job_config_check_mats(BgwJob *job, Jsonb *config) name = list_make2(makeString(NameStr(job->fd.check_schema)), makeString(NameStr(job->fd.check_name))); proc = LookupFuncName(name, 2, proc_args, false); - args = - list_make2(makeConst(INT4OID, -1, InvalidOid, 4, Int32GetDatum(job->fd.id), false, true), - makeConst(JSONBOID, -1, InvalidOid, -1, JsonbPGetDatum(config), false, false)); - funcexpr = makeFuncExpr(proc, VOIDOID, args, InvalidOid, InvalidOid, COERCE_EXPLICIT_CALL); - switch (get_func_prokind(proc)) - { - case PROKIND_FUNCTION: - job_execute_function(funcexpr); - break; - case PROKIND_PROCEDURE: - job_execute_procedure(funcexpr); - break; - default: - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("unsupported function type"))); - break; - } - + ts_bgw_job_run_config_check(proc, job->fd.id, config); if (started) { /* if job does its own transaction handling it might not have set a snapshot */ @@ -175,10 +191,6 @@ bgw_job_from_tupleinfo(TupleInfo *ti, size_t alloc_size) Assert(alloc_size >= sizeof(BgwJob)); job = MemoryContextAllocZero(ti->mctx, alloc_size); tuple = ts_scanner_fetch_heap_tuple(ti, false, &should_free); - memcpy(job, GETSTRUCT(tuple), sizeof(FormData_bgw_job)); - - if (should_free) - heap_freetuple(tuple); /* * Using heap_deform_tuple instead of GETSTRUCT since the tuple can @@ -241,6 +253,7 @@ bgw_job_from_tupleinfo(TupleInfo *ti, size_t alloc_size) if (!nulls[AttrNumberGetAttrOffset(Anum_bgw_job_config)]) job->fd.config = DatumGetJsonbP(values[AttrNumberGetAttrOffset(Anum_bgw_job_config)]); + MemoryContextSwitchTo(old_ctx); if (should_free) heap_freetuple(tuple); @@ -768,10 +781,7 @@ bgw_job_tuple_update_by_id(TupleInfo *ti, void *const data) repl[AttrNumberGetAttrOffset(Anum_bgw_job_config)] = true; if (updated_job->fd.config) { - // ts_cm_functions->job_config_check(&updated_job->fd.proc_schema, - // &updated_job->fd.proc_name, - // updated_job->fd.config); - job_config_check_mats(bgw_job_from_tupleinfo(ti, sizeof(BgwJob)), updated_job->fd.config); + job_config_check(bgw_job_from_tupleinfo(ti, sizeof(BgwJob)), updated_job->fd.config); values[AttrNumberGetAttrOffset(Anum_bgw_job_config)] = JsonbPGetDatum(updated_job->fd.config); } @@ -1131,10 +1141,11 @@ ts_bgw_job_run_and_set_next_start(BgwJob *job, job_main_func func, int64 initial return ret; } -int ts_bgw_job_insert_relation( - Name application_name, Interval *schedule_interval, Interval *max_runtime, - int32 max_retries, Interval *retry_period, Name proc_schema, Name proc_name, Name check_schema, - Name check_name, Name owner, bool scheduled, int32 hypertable_id, Jsonb *config) +int +ts_bgw_job_insert_relation(Name application_name, Interval *schedule_interval, + Interval *max_runtime, int32 max_retries, Interval *retry_period, + Name proc_schema, Name proc_name, Name check_schema, Name check_name, + Name owner, bool scheduled, int32 hypertable_id, Jsonb *config) { Catalog *catalog = ts_catalog_get(); Relation rel; diff --git a/src/bgw/job.h b/src/bgw/job.h index 57f294235ca..c73f12c55c3 100644 --- a/src/bgw/job.h +++ b/src/bgw/job.h @@ -42,14 +42,15 @@ extern TimestampTz ts_bgw_job_timeout_at(BgwJob *job, TimestampTz start_time); extern TSDLLEXPORT bool ts_bgw_job_delete_by_id(int32 job_id); extern TSDLLEXPORT bool ts_bgw_job_update_by_id(int32 job_id, BgwJob *job); extern TSDLLEXPORT int32 ts_bgw_job_insert_relation( - Name application_name, Interval *schedule_interval, Interval *max_runtime, - int32 max_retries, Interval *retry_period, Name proc_schema, Name proc_name, Name check_schema, - Name check_name, Name owner, bool scheduled, int32 hypertable_id, Jsonb *config); + Name application_name, Interval *schedule_interval, Interval *max_runtime, int32 max_retries, + Interval *retry_period, Name proc_schema, Name proc_name, Name check_schema, Name check_name, + Name owner, bool scheduled, int32 hypertable_id, Jsonb *config); extern TSDLLEXPORT void ts_bgw_job_permission_check(BgwJob *job); extern TSDLLEXPORT void ts_bgw_job_validate_job_owner(Oid owner); extern bool ts_bgw_job_execute(BgwJob *job); +extern TSDLLEXPORT void ts_bgw_job_run_config_check(Oid check, int32 job_id, Jsonb *config); extern TSDLLEXPORT Datum ts_bgw_job_entrypoint(PG_FUNCTION_ARGS); extern void ts_bgw_job_set_scheduler_test_hook(scheduler_test_hook_type hook); diff --git a/src/cross_module_fn.c b/src/cross_module_fn.c index 49ed162acd2..3a5032d39bf 100644 --- a/src/cross_module_fn.c +++ b/src/cross_module_fn.c @@ -176,13 +176,6 @@ job_execute_default_fn(BgwJob *job) pg_unreachable(); } -static void -job_config_check_default_fn(Name proc_schema, Name proc_name, Jsonb *config) -{ - error_no_default_fn_community(); - pg_unreachable(); -} - static bool process_compress_table_default(AlterTableCmd *cmd, Hypertable *ht, WithClauseResult *with_clause_options) @@ -401,7 +394,6 @@ TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default = { .job_delete = error_no_default_fn_pg_community, .job_run = error_no_default_fn_pg_community, .job_execute = job_execute_default_fn, - .job_config_check = job_config_check_default_fn, .move_chunk = error_no_default_fn_pg_community, .move_chunk_proc = error_no_default_fn_pg_community, diff --git a/src/cross_module_fn.h b/src/cross_module_fn.h index 28c9ffe47c8..1037d2353b1 100644 --- a/src/cross_module_fn.h +++ b/src/cross_module_fn.h @@ -63,7 +63,6 @@ typedef struct CrossModuleFunctions PGFunction job_run; bool (*job_execute)(BgwJob *job); - void (*job_config_check)(Name proc_schema, Name proc_name, Jsonb *config); void (*create_upper_paths_hook)(PlannerInfo *, UpperRelationKind, RelOptInfo *, RelOptInfo *, TsRelType input_reltype, Hypertable *ht, void *extra); diff --git a/tsl/src/bgw_policy/compression_api.c b/tsl/src/bgw_policy/compression_api.c index 56e05047b42..45eab08dd62 100644 --- a/tsl/src/bgw_policy/compression_api.c +++ b/tsl/src/bgw_policy/compression_api.c @@ -174,7 +174,11 @@ policy_compression_check(PG_FUNCTION_ARGS) { if (PG_NARGS() != 2 || PG_ARGISNULL(0) || PG_ARGISNULL(1)) PG_RETURN_VOID(); - policy_compression_validate(PG_GETARG_INT32(0), PG_GETARG_JSONB_P(1)); + + PolicyCompressionData policy_data; + policy_compression_read_and_validate_config(PG_GETARG_JSONB_P(1), &policy_data); + ts_cache_release(policy_data.hcache); + PG_RETURN_VOID(); } diff --git a/tsl/src/bgw_policy/continuous_aggregate_api.c b/tsl/src/bgw_policy/continuous_aggregate_api.c index c4455a92d28..c8ebad58fbd 100644 --- a/tsl/src/bgw_policy/continuous_aggregate_api.c +++ b/tsl/src/bgw_policy/continuous_aggregate_api.c @@ -226,7 +226,7 @@ policy_refresh_cagg_check(PG_FUNCTION_ARGS) if (PG_NARGS() != 2 || PG_ARGISNULL(0) || PG_ARGISNULL(1)) PG_RETURN_VOID(); - policy_refresh_cagg_validate(PG_GETARG_INT32(0), PG_GETARG_JSONB_P(1)); + policy_refresh_cagg_read_and_validate_config(PG_GETARG_JSONB_P(1), NULL); PG_RETURN_VOID(); } diff --git a/tsl/src/bgw_policy/job.c b/tsl/src/bgw_policy/job.c index 6c08106cb6b..39067c8893e 100644 --- a/tsl/src/bgw_policy/job.c +++ b/tsl/src/bgw_policy/job.c @@ -202,85 +202,6 @@ check_valid_index(Hypertable *ht, const char *index_name) ReleaseSysCache(idxtuple); } -void -policy_reorder_validate(int32 job_id, Jsonb *config) -{ - int32 htid = policy_reorder_get_hypertable_id(config); - Hypertable *ht = ts_hypertable_get_by_id(htid); - if (!ht) - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("configuration hypertable id %d not found", htid))); - - check_valid_index(ht, policy_reorder_get_index_name(config)); -} - - -void -policy_retention_validate(int32 job_id, Jsonb *config) -{ - Oid object_relid; - Hypertable *hypertable; - Cache *hcache; - const Dimension *open_dim; - - object_relid = ts_hypertable_id_to_relid(policy_retention_get_hypertable_id(config)); - hypertable = ts_hypertable_cache_get_cache_and_entry(object_relid, CACHE_FLAG_NONE, &hcache); - open_dim = get_open_dimension_for_hypertable(hypertable); - - /* We only care about the errors from this function, so we ignore the - * return value. */ - get_window_boundary(open_dim, - config, - policy_retention_get_drop_after_int, - policy_retention_get_drop_after_interval); - - ts_cache_release(hcache); -} - -void -policy_refresh_cagg_validate(int32 job_id, Jsonb *config) -{ - int32 materialization_id; - Hypertable *mat_ht; - const Dimension *open_dim; - Oid dim_type; - int64 refresh_start, refresh_end; - - materialization_id = policy_continuous_aggregate_get_mat_hypertable_id(config); - mat_ht = ts_hypertable_get_by_id(materialization_id); - open_dim = get_open_dimension_for_hypertable(mat_ht); - dim_type = ts_dimension_get_partition_type(open_dim); - refresh_start = policy_refresh_cagg_get_refresh_start(open_dim, config); - refresh_end = policy_refresh_cagg_get_refresh_end(open_dim, config); - - if (refresh_start >= refresh_end) - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid refresh window"), - errdetail("start_offset: %s, end_offset: %s", - ts_internal_to_time_string(refresh_start, dim_type), - ts_internal_to_time_string(refresh_end, dim_type)), - errhint("The start of the window must be before the end."))); -} - -void -policy_compression_validate(int32 job_id, Jsonb *config) -{ - Cache *hcache; - Oid table_relid = ts_hypertable_id_to_relid(policy_compression_get_hypertable_id(config)); - Hypertable *ht = ts_hypertable_cache_get_cache_and_entry(table_relid, CACHE_FLAG_NONE, &hcache); - const Dimension *dim = hyperspace_get_open_dimension(ht->space, 0); - - /* We ignore the return value from this function since we just try to read - * the config to see that it does not generate any errors. */ - get_window_boundary(dim, - config, - policy_compression_get_compress_after_int, - policy_compression_get_compress_after_interval); - ts_cache_release(hcache); -} - bool policy_reorder_execute(int32 job_id, Jsonb *config) { @@ -329,13 +250,13 @@ policy_reorder_read_and_validate_config(Jsonb *config, PolicyReorderData *policy { int32 htid = policy_reorder_get_hypertable_id(config); Hypertable *ht = ts_hypertable_get_by_id(htid); - const char *index_name = policy_reorder_get_index_name(config); if (!ht) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("configuration hypertable id %d not found", htid))); + const char *index_name = policy_reorder_get_index_name(config); check_valid_index(ht, index_name); if (policy) @@ -749,26 +670,3 @@ job_execute(BgwJob *job) return true; } - -/* - * Check configuration for a job type. - */ -void -job_config_check(Name proc_schema, Name proc_name, Jsonb *config) -{ - if (namestrcmp(proc_schema, INTERNAL_SCHEMA_NAME) == 0) - { - if (namestrcmp(proc_name, "policy_retention") == 0) - policy_retention_read_and_validate_config(config, NULL); - else if (namestrcmp(proc_name, "policy_reorder") == 0) - policy_reorder_read_and_validate_config(config, NULL); - else if (namestrcmp(proc_name, "policy_compression") == 0) - { - PolicyCompressionData policy_data; - policy_compression_read_and_validate_config(config, &policy_data); - ts_cache_release(policy_data.hcache); - } - else if (namestrcmp(proc_name, "policy_refresh_continuous_aggregate") == 0) - policy_refresh_cagg_read_and_validate_config(config, NULL); - } -} diff --git a/tsl/src/bgw_policy/job.h b/tsl/src/bgw_policy/job.h index 5552e072323..4248d2c12ad 100644 --- a/tsl/src/bgw_policy/job.h +++ b/tsl/src/bgw_policy/job.h @@ -49,13 +49,9 @@ typedef void (*reorder_func)(Oid tableOid, Oid indexOid, bool verbose, Oid wait_ /* Functions exposed only for testing */ extern bool policy_reorder_execute(int32 job_id, Jsonb *config); -extern void policy_reorder_validate(int32 job_id, Jsonb *config); extern bool policy_retention_execute(int32 job_id, Jsonb *config); -extern void policy_retention_validate(int32 job_id, Jsonb *config); extern bool policy_refresh_cagg_execute(int32 job_id, Jsonb *config); -extern void policy_refresh_cagg_validate(int32 job_id, Jsonb *config); extern bool policy_recompression_execute(int32 job_id, Jsonb *config); -extern void policy_compression_validate(int32 job_id, Jsonb *config); extern void policy_reorder_read_and_validate_config(Jsonb *config, PolicyReorderData *policy_data); extern void policy_retention_read_and_validate_config(Jsonb *config, PolicyRetentionData *policy_data); @@ -66,7 +62,5 @@ extern void policy_compression_read_and_validate_config(Jsonb *config, extern void policy_recompression_read_and_validate_config(Jsonb *config, PolicyCompressionData *policy_data); extern bool job_execute(BgwJob *job); -extern void job_config_check(Name proc_schema, Name proc_name, Jsonb *config); -// extern void job_config_check_mats(BgwJob *job, Jsonb *config); #endif /* TIMESCALEDB_TSL_BGW_POLICY_JOB_H */ diff --git a/tsl/src/bgw_policy/job_api.c b/tsl/src/bgw_policy/job_api.c index 9cd446349ae..5a43875214d 100644 --- a/tsl/src/bgw_policy/job_api.c +++ b/tsl/src/bgw_policy/job_api.c @@ -82,7 +82,7 @@ job_add(PG_FUNCTION_ARGS) errmsg("permission denied for function \"%s\"", func_name), errhint("Job owner must have EXECUTE privilege on the function."))); - if (check != InvalidOid) + if (OidIsValid(check)) { check_name_str = get_func_name(check); if (check_name_str == NULL) @@ -110,7 +110,7 @@ job_add(PG_FUNCTION_ARGS) namestrcpy(&owner_name, GetUserNameFromId(owner, false)); if (config) - job_config_check(&proc_schema, &proc_name, config); + ts_bgw_job_run_config_check(check, 0, config); job_id = ts_bgw_job_insert_relation(&application_name, schedule_interval, @@ -125,7 +125,6 @@ job_add(PG_FUNCTION_ARGS) scheduled, 0, config); - if (!PG_ARGISNULL(3)) { TimestampTz initial_start = PG_GETARG_TIMESTAMPTZ(3); diff --git a/tsl/src/bgw_policy/reorder_api.c b/tsl/src/bgw_policy/reorder_api.c index 8ae48dbee9d..a77e46ed1f5 100644 --- a/tsl/src/bgw_policy/reorder_api.c +++ b/tsl/src/bgw_policy/reorder_api.c @@ -114,7 +114,7 @@ policy_reorder_check(PG_FUNCTION_ARGS) TS_PREVENT_FUNC_IF_READ_ONLY(); - policy_reorder_validate(PG_GETARG_INT32(0), PG_GETARG_JSONB_P(1)); + policy_reorder_read_and_validate_config(PG_GETARG_JSONB_P(1), NULL); PG_RETURN_VOID(); } diff --git a/tsl/src/bgw_policy/retention_api.c b/tsl/src/bgw_policy/retention_api.c index d5bf57bc430..524249ad270 100644 --- a/tsl/src/bgw_policy/retention_api.c +++ b/tsl/src/bgw_policy/retention_api.c @@ -52,7 +52,7 @@ policy_retention_check(PG_FUNCTION_ARGS) TS_PREVENT_FUNC_IF_READ_ONLY(); - policy_retention_validate(PG_GETARG_INT32(0), PG_GETARG_JSONB_P(1)); + policy_retention_read_and_validate_config(PG_GETARG_JSONB_P(1), NULL); PG_RETURN_VOID(); } diff --git a/tsl/src/init.c b/tsl/src/init.c index e54ed7607c7..f3d713b89bc 100644 --- a/tsl/src/init.c +++ b/tsl/src/init.c @@ -115,7 +115,6 @@ CrossModuleFunctions tsl_cm_functions = { .job_delete = job_delete, .job_run = job_run, .job_execute = job_execute, - .job_config_check = job_config_check, /* gapfill */ .gapfill_marker = gapfill_marker, diff --git a/tsl/test/expected/bgw_db_scheduler.out b/tsl/test/expected/bgw_db_scheduler.out index 0861e87e2e0..f620b1cbc7c 100644 --- a/tsl/test/expected/bgw_db_scheduler.out +++ b/tsl/test/expected/bgw_db_scheduler.out @@ -265,9 +265,9 @@ SELECT insert_job('test_job_1', 'bgw_test_job_1', INTERVAL '100ms', INTERVAL '10 (1 row) select * from _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+------------------+-------------------+-----------------+-------------+--------------+-------------+----------------+------------+-----------+---------------+-------- - 1000 | test_job_1 | @ 0.1 secs | @ 1 min 40 secs | 5 | @ 1 sec | public | bgw_test_job_1 | super_user | t | | + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+------------------+-------------------+-----------------+-------------+--------------+-------------+----------------+------------+-----------+---------------+--------+--------------+------------ + 1000 | test_job_1 | @ 0.1 secs | @ 1 min 40 secs | 5 | @ 1 sec | public | bgw_test_job_1 | super_user | t | | | | (1 row) \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER @@ -1172,9 +1172,9 @@ SELECT insert_job('test_job_4', 'bgw_test_job_4', INTERVAL '100ms', INTERVAL '10 (1 row) select * from _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+------------------+-------------------+-----------------+-------------+--------------+-------------+----------------+------------+-----------+---------------+-------- - 1014 | test_job_4 | @ 0.1 secs | @ 1 min 40 secs | 5 | @ 1 sec | public | bgw_test_job_4 | super_user | t | | + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+------------------+-------------------+-----------------+-------------+--------------+-------------+----------------+------------+-----------+---------------+--------+--------------+------------ + 1014 | test_job_4 | @ 0.1 secs | @ 1 min 40 secs | 5 | @ 1 sec | public | bgw_test_job_4 | super_user | t | | | | (1 row) \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER diff --git a/tsl/test/expected/bgw_policy.out b/tsl/test/expected/bgw_policy.out index ef9e7190104..3fb8a47c09e 100644 --- a/tsl/test/expected/bgw_policy.out +++ b/tsl/test/expected/bgw_policy.out @@ -32,9 +32,9 @@ SELECT COUNT(*) FROM _timescaledb_catalog.chunk as c, _timescaledb_catalog.hyper -- by starting with oldest chunks select add_reorder_policy('test_table', 'test_table_time_idx') as reorder_job_id \gset select * from _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+----------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+-----------------------------------------------------------+-----------------------+---------------------- + 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} | _timescaledb_internal | policy_reorder_check (1 row) select job_id, chunk_id, num_times_job_run from _timescaledb_internal.bgw_policy_chunk_stats; diff --git a/tsl/test/expected/bgw_reorder_drop_chunks.out b/tsl/test/expected/bgw_reorder_drop_chunks.out index 4caa56105ad..1ec49c4841d 100644 --- a/tsl/test/expected/bgw_reorder_drop_chunks.out +++ b/tsl/test/expected/bgw_reorder_drop_chunks.out @@ -54,8 +54,8 @@ SELECT ts_bgw_params_create(); (1 row) SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) SELECT * FROM timescaledb_information.job_stats; diff --git a/tsl/test/expected/cagg_bgw.out b/tsl/test/expected/cagg_bgw.out index 23e9a48cb71..7dba976f1e0 100644 --- a/tsl/test/expected/cagg_bgw.out +++ b/tsl/test/expected/cagg_bgw.out @@ -58,8 +58,8 @@ SELECT ts_bgw_params_create(); (1 row) SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) SELECT * FROM timescaledb_information.job_stats; @@ -121,9 +121,9 @@ SELECT mat_hypertable_id FROM _timescaledb_catalog.continuous_agg \gset SELECT id AS job_id FROM _timescaledb_config.bgw_job where hypertable_id=:mat_hypertable_id \gset -- job was created SELECT * FROM _timescaledb_config.bgw_job where hypertable_id=:mat_hypertable_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+----------------------------------------------------------------- - 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+-----------------------------------------------------------------+-----------------------+----------------------------------- + 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} | _timescaledb_internal | policy_check_continuous_aggregate (1 row) -- create 10 time buckets @@ -160,9 +160,9 @@ SELECT * FROM sorted_bgw_log; (3 rows) SELECT * FROM _timescaledb_config.bgw_job where id=:job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+----------------------------------------------------------------- - 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+-----------------------------------------------------------------+-----------------------+----------------------------------- + 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} | _timescaledb_internal | policy_check_continuous_aggregate (1 row) -- job ran once, successfully diff --git a/tsl/test/expected/cagg_bgw_dist_ht.out b/tsl/test/expected/cagg_bgw_dist_ht.out index 87d0e425ff6..9066f1596c9 100644 --- a/tsl/test/expected/cagg_bgw_dist_ht.out +++ b/tsl/test/expected/cagg_bgw_dist_ht.out @@ -90,8 +90,8 @@ SELECT ts_bgw_params_create(); (1 row) SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) SELECT * FROM timescaledb_information.job_stats; @@ -153,9 +153,9 @@ SELECT mat_hypertable_id FROM _timescaledb_catalog.continuous_agg \gset SELECT id AS job_id FROM _timescaledb_config.bgw_job where hypertable_id=:mat_hypertable_id \gset -- job was created SELECT * FROM _timescaledb_config.bgw_job where hypertable_id=:mat_hypertable_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+----------------------------------------------------------------- - 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+-----------------------------------------------------------------+-----------------------+----------------------------------- + 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} | _timescaledb_internal | policy_check_continuous_aggregate (1 row) -- create 10 time buckets @@ -192,9 +192,9 @@ SELECT * FROM sorted_bgw_log; (3 rows) SELECT * FROM _timescaledb_config.bgw_job where id=:job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+----------------------------------------------------------------- - 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+-----------------------------------------------------------------+-----------------------+----------------------------------- + 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 4, "start_offset": null, "mat_hypertable_id": 2} | _timescaledb_internal | policy_check_continuous_aggregate (1 row) -- job ran once, successfully diff --git a/tsl/test/expected/cagg_errors.out b/tsl/test/expected/cagg_errors.out index 470695ce1f2..632ae64f6e0 100644 --- a/tsl/test/expected/cagg_errors.out +++ b/tsl/test/expected/cagg_errors.out @@ -487,18 +487,21 @@ GROUP BY 1 WITH NO DATA; SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": null}'); ERROR: could not find "mat_hypertable_id" in config for job -- ... this one because it has a bad value for start_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": "1 fortnight", "mat_hypertable_id": 11}'); ERROR: invalid input syntax for type interval: "1 fortnight" -- ... this one because it has a bad value for end_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": "chicken", "start_offset": null, "mat_hypertable_id": 11}'); ERROR: invalid input syntax for type interval: "chicken" \set ON_ERROR_STOP 1 @@ -519,6 +522,8 @@ owner | default_perm_user scheduled | t hypertable_id | 11 config | {"end_offset": null, "start_offset": null, "mat_hypertable_id": 11} +check_schema | _timescaledb_internal +check_name | policy_check_continuous_aggregate \x off -- These are all weird values for the parameters for the continuous diff --git a/tsl/test/expected/cagg_errors_deprecated.out b/tsl/test/expected/cagg_errors_deprecated.out index 99931921526..5ada53af9eb 100644 --- a/tsl/test/expected/cagg_errors_deprecated.out +++ b/tsl/test/expected/cagg_errors_deprecated.out @@ -543,18 +543,21 @@ GROUP BY 1 WITH NO DATA; SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": null}'); ERROR: could not find "mat_hypertable_id" in config for job -- ... this one because it has a bad value for start_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": "1 fortnight", "mat_hypertable_id": 11}'); ERROR: invalid input syntax for type interval: "1 fortnight" -- ... this one because it has a bad value for end_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": "chicken", "start_offset": null, "mat_hypertable_id": 11}'); ERROR: invalid input syntax for type interval: "chicken" \set ON_ERROR_STOP 1 @@ -575,6 +578,8 @@ owner | default_perm_user scheduled | t hypertable_id | 11 config | {"end_offset": null, "start_offset": null, "mat_hypertable_id": 11} +check_schema | _timescaledb_internal +check_name | policy_check_continuous_aggregate \x off -- These are all weird values for the parameters for the continuous diff --git a/tsl/test/expected/compress_bgw_reorder_drop_chunks.out b/tsl/test/expected/compress_bgw_reorder_drop_chunks.out index e7879b2971c..3ee50ff4d90 100644 --- a/tsl/test/expected/compress_bgw_reorder_drop_chunks.out +++ b/tsl/test/expected/compress_bgw_reorder_drop_chunks.out @@ -87,9 +87,9 @@ SELECT alter_job(:retention_job_id, schedule_interval => INTERVAL '1 second'); (1 row) SELECT * FROM _timescaledb_config.bgw_job where id=:retention_job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------ - 1000 | Retention Policy [1000] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 4 mons", "hypertable_id": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------+-----------------------+------------------------ + 1000 | Retention Policy [1000] | @ 1 sec | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 4 mons", "hypertable_id": 1} | _timescaledb_internal | policy_retention_check (1 row) --turn on compression and compress all chunks diff --git a/tsl/test/expected/compression_bgw.out b/tsl/test/expected/compression_bgw.out index a5dc5568579..63e8ba6e7e6 100644 --- a/tsl/test/expected/compression_bgw.out +++ b/tsl/test/expected/compression_bgw.out @@ -32,9 +32,9 @@ select generate_series('2018-12-01 00:00'::timestamp, '2018-12-31 00:00'::timest select add_compression_policy('conditions', '60d'::interval) AS compressjob_id \gset select * from _timescaledb_config.bgw_job where id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+--------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+----------------------------------------------------- - 1000 | Compression Policy [1000] | @ 15 days 12 hours | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 1 | {"hypertable_id": 1, "compress_after": "@ 60 days"} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+--------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+-----------------------------------------------------+-----------------------+-------------------------- + 1000 | Compression Policy [1000] | @ 15 days 12 hours | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 1 | {"hypertable_id": 1, "compress_after": "@ 60 days"} | _timescaledb_internal | policy_compression_check (1 row) select * from alter_job(:compressjob_id, schedule_interval=>'1s'); @@ -52,9 +52,9 @@ SELECT alter_job(id,config:=jsonb_set(config,'{maxchunks_to_compress}', '1')) (1 row) select * from _timescaledb_config.bgw_job where id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+--------------------------------------------------------------------------------- - 1000 | Compression Policy [1000] | @ 1 sec | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 1 | {"hypertable_id": 1, "compress_after": "@ 60 days", "maxchunks_to_compress": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+---------------------------------------------------------------------------------+-----------------------+-------------------------- + 1000 | Compression Policy [1000] | @ 1 sec | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 1 | {"hypertable_id": 1, "compress_after": "@ 60 days", "maxchunks_to_compress": 1} | _timescaledb_internal | policy_compression_check (1 row) insert into conditions @@ -157,9 +157,9 @@ ERROR: unsupported compress_after argument type, expected type : smallint \set ON_ERROR_STOP 1 SELECT add_compression_policy('test_table_smallint', 2::SMALLINT) AS compressjob_id \gset SELECT * FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+------------------------------------------- - 1001 | Compression Policy [1001] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 3 | {"hypertable_id": 3, "compress_after": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+-------------------------------------------+-----------------------+-------------------------- + 1001 | Compression Policy [1001] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 3 | {"hypertable_id": 3, "compress_after": 2} | _timescaledb_internal | policy_compression_check (1 row) --will compress all chunks that need compression @@ -194,9 +194,9 @@ INSERT INTO test_table_integer SELECT generate_series(1,5), 10; ALTER TABLE test_table_integer SET (timescaledb.compress); SELECT add_compression_policy('test_table_integer', 2::INTEGER) AS compressjob_id \gset SELECT * FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+------------------------------------------- - 1002 | Compression Policy [1002] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 5 | {"hypertable_id": 5, "compress_after": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+-------------------------------------------+-----------------------+-------------------------- + 1002 | Compression Policy [1002] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 5 | {"hypertable_id": 5, "compress_after": 2} | _timescaledb_internal | policy_compression_check (1 row) --will compress all chunks that need compression @@ -231,9 +231,9 @@ INSERT INTO test_table_bigint SELECT generate_series(1,5), 10; ALTER TABLE test_table_bigint SET (timescaledb.compress); SELECT add_compression_policy('test_table_bigint', 2::BIGINT) AS compressjob_id \gset SELECT * FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+------------------------------------------- - 1003 | Compression Policy [1003] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 7 | {"hypertable_id": 7, "compress_after": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------------+-----------+---------------+-------------------------------------------+-----------------------+-------------------------- + 1003 | Compression Policy [1003] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | default_perm_user | t | 7 | {"hypertable_id": 7, "compress_after": 2} | _timescaledb_internal | policy_compression_check (1 row) --will compress all chunks that need compression diff --git a/tsl/test/expected/continuous_aggs.out b/tsl/test/expected/continuous_aggs.out index 143567332aa..4bd463ce620 100644 --- a/tsl/test/expected/continuous_aggs.out +++ b/tsl/test/expected/continuous_aggs.out @@ -14,8 +14,8 @@ AS :TSL_MODULE_PATHNAME, 'ts_test_continuous_agg_find_by_view_name' LANGUAGE C; DELETE FROM _timescaledb_config.bgw_job; SET ROLE :ROLE_DEFAULT_PERM_USER; SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) --TEST1 --- @@ -53,9 +53,9 @@ group by time_bucket(1, a), a WITH NO DATA; SELECT add_continuous_aggregate_policy('mat_m1', NULL, 2::integer, '12 h'::interval) AS job_id \gset SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+----------------------------------------------------------------- - 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 2, "start_offset": null, "mat_hypertable_id": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+-----------------------------------------------------------------+-----------------------+----------------------------------- + 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 2, "start_offset": null, "mat_hypertable_id": 2} | _timescaledb_internal | policy_check_continuous_aggregate (1 row) SELECT ca.raw_hypertable_id as "RAW_HYPERTABLE_ID", @@ -103,8 +103,8 @@ SHOW enable_partitionwise_aggregate; SET enable_partitionwise_aggregate = on; SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) CREATE TABLE conditions ( @@ -802,8 +802,8 @@ select count(*) from _timescaledb_catalog.continuous_aggs_materialization_invali (1 row) SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) --mat table, user_view, and partial view all gone diff --git a/tsl/test/expected/continuous_aggs_deprecated.out b/tsl/test/expected/continuous_aggs_deprecated.out index 92ed57dcffa..b29765c6b79 100644 --- a/tsl/test/expected/continuous_aggs_deprecated.out +++ b/tsl/test/expected/continuous_aggs_deprecated.out @@ -14,8 +14,8 @@ AS :TSL_MODULE_PATHNAME, 'ts_test_continuous_agg_find_by_view_name' LANGUAGE C; DELETE FROM _timescaledb_config.bgw_job; SET ROLE :ROLE_DEFAULT_PERM_USER; SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) --TEST1 --- @@ -53,9 +53,9 @@ group by time_bucket(1, a), a WITH NO DATA; SELECT add_continuous_aggregate_policy('mat_m1', NULL, 2::integer, '12 h'::interval) AS job_id \gset SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+----------------------------------------------------------------- - 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 2, "start_offset": null, "mat_hypertable_id": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+--------------------------------------------+-------------------+-------------+-------------+--------------+-----------------------+-------------------------------------+-------------------+-----------+---------------+-----------------------------------------------------------------+-----------------------+----------------------------------- + 1000 | Refresh Continuous Aggregate Policy [1000] | @ 12 hours | @ 0 | -1 | @ 12 hours | _timescaledb_internal | policy_refresh_continuous_aggregate | default_perm_user | t | 2 | {"end_offset": 2, "start_offset": null, "mat_hypertable_id": 2} | _timescaledb_internal | policy_check_continuous_aggregate (1 row) SELECT ca.raw_hypertable_id as "RAW_HYPERTABLE_ID", @@ -104,8 +104,8 @@ SHOW enable_partitionwise_aggregate; SET enable_partitionwise_aggregate = on; SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) CREATE TABLE conditions ( @@ -815,8 +815,8 @@ select count(*) from _timescaledb_catalog.continuous_aggs_materialization_invali (1 row) SELECT * FROM _timescaledb_config.bgw_job; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) --mat table, user_view, and partial view all gone diff --git a/tsl/test/expected/dist_compression.out b/tsl/test/expected/dist_compression.out index 5fe99788627..684ffa2932b 100644 --- a/tsl/test/expected/dist_compression.out +++ b/tsl/test/expected/dist_compression.out @@ -654,9 +654,9 @@ select generate_series('2018-12-01 00:00'::timestamp, '2018-12-31 00:00'::timest select add_compression_policy('conditions', '60d'::interval) AS compressjob_id \gset select * from _timescaledb_config.bgw_job where id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+--------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+----------------------------------------------------- - 1000 | Compression Policy [1000] | @ 15 days 12 hours | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 2 | {"hypertable_id": 2, "compress_after": "@ 60 days"} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+--------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+-----------------------------------------------------+-----------------------+-------------------------- + 1000 | Compression Policy [1000] | @ 15 days 12 hours | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 2 | {"hypertable_id": 2, "compress_after": "@ 60 days"} | _timescaledb_internal | policy_compression_check (1 row) select * from alter_job(:compressjob_id, schedule_interval=>'1s'); @@ -666,9 +666,9 @@ select * from alter_job(:compressjob_id, schedule_interval=>'1s'); (1 row) select * from _timescaledb_config.bgw_job where id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+----------------------------------------------------- - 1000 | Compression Policy [1000] | @ 1 sec | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 2 | {"hypertable_id": 2, "compress_after": "@ 60 days"} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+-----------------------------------------------------+-----------------------+-------------------------- + 1000 | Compression Policy [1000] | @ 1 sec | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 2 | {"hypertable_id": 2, "compress_after": "@ 60 days"} | _timescaledb_internal | policy_compression_check (1 row) -- we want only 1 chunk to be compressed -- @@ -768,9 +768,9 @@ INSERT INTO test_table_smallint SELECT generate_series(1,5), 10; ALTER TABLE test_table_smallint SET (timescaledb.compress); SELECT add_compression_policy('test_table_smallint', 2::int) AS compressjob_id \gset SELECT * FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+------------------------------------------- - 1001 | Compression Policy [1001] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 3 | {"hypertable_id": 3, "compress_after": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+-------------------------------------------+-----------------------+-------------------------- + 1001 | Compression Policy [1001] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 3 | {"hypertable_id": 3, "compress_after": 2} | _timescaledb_internal | policy_compression_check (1 row) CALL run_job(:compressjob_id); @@ -810,9 +810,9 @@ INSERT INTO test_table_integer SELECT generate_series(1,5), 10; ALTER TABLE test_table_integer SET (timescaledb.compress); SELECT add_compression_policy('test_table_integer', 2::int) AS compressjob_id \gset SELECT * FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+------------------------------------------- - 1002 | Compression Policy [1002] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 4 | {"hypertable_id": 4, "compress_after": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+-------------------------------------------+-----------------------+-------------------------- + 1002 | Compression Policy [1002] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 4 | {"hypertable_id": 4, "compress_after": 2} | _timescaledb_internal | policy_compression_check (1 row) CALL run_job(:compressjob_id); @@ -852,9 +852,9 @@ INSERT INTO test_table_bigint SELECT generate_series(1,5), 10; ALTER TABLE test_table_bigint SET (timescaledb.compress); SELECT add_compression_policy('test_table_bigint', 2::int) AS compressjob_id \gset SELECT * FROM _timescaledb_config.bgw_job WHERE id = :compressjob_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+------------------------------------------- - 1003 | Compression Policy [1003] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 5 | {"hypertable_id": 5, "compress_after": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+---------------------------+-------------------+-------------+-------------+--------------+-----------------------+--------------------+-------------+-----------+---------------+-------------------------------------------+-----------------------+-------------------------- + 1003 | Compression Policy [1003] | @ 1 day | @ 0 | -1 | @ 1 hour | _timescaledb_internal | policy_compression | test_role_1 | t | 5 | {"hypertable_id": 5, "compress_after": 2} | _timescaledb_internal | policy_compression_check (1 row) CALL run_job(:compressjob_id); diff --git a/tsl/test/expected/tsl_tables.out b/tsl/test/expected/tsl_tables.out index 1c791382d37..95a18b28555 100644 --- a/tsl/test/expected/tsl_tables.out +++ b/tsl/test/expected/tsl_tables.out @@ -7,8 +7,8 @@ CREATE OR REPLACE FUNCTION ts_test_chunk_stats_insert(job_id INTEGER, chunk_id I AS :TSL_MODULE_PATHNAME LANGUAGE C VOLATILE; \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) CREATE TABLE test_table(time timestamptz, junk int); @@ -74,9 +74,9 @@ select add_reorder_policy(2, 'third_index'); ERROR: OID 2 does not refer to a table \set ON_ERROR_STOP 1 select * from _timescaledb_config.bgw_job where id=:job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+----------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+-----------------------------------------------------------+-----------------------+---------------------- + 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} | _timescaledb_internal | policy_reorder_check (1 row) -- Now check that default scheduling interval for reorder policy is calculated correctly @@ -96,18 +96,18 @@ select add_reorder_policy('test_table2', 'test_table2_time_idx'); (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+------------------------------------------------------------ - 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} - 1001 | Reorder Policy [1001] | @ 12 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 3 | {"index_name": "test_table2_time_idx", "hypertable_id": 3} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+------------------------------------------------------------+-----------------------+---------------------- + 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} | _timescaledb_internal | policy_reorder_check + 1001 | Reorder Policy [1001] | @ 12 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 3 | {"index_name": "test_table2_time_idx", "hypertable_id": 3} | _timescaledb_internal | policy_reorder_check (2 rows) DROP TABLE test_table2; -- Make sure that test_table2 reorder policy gets dropped SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+----------------------------------------------------------- - 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+-----------------------------------------------------------+-----------------------+---------------------- + 1000 | Reorder Policy [1000] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 1 | {"index_name": "test_table_time_idx", "hypertable_id": 1} | _timescaledb_internal | policy_reorder_check (1 row) -- Error whenever incorrect arguments are applied (must have table and interval) @@ -163,9 +163,9 @@ WARNING: retention policy already exists for hypertable "test_table" (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE proc_name = 'policy_retention' ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------ - 1002 | Retention Policy [1002] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 3 mons", "hypertable_id": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------+-----------------------+------------------------ + 1002 | Retention Policy [1002] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 3 mons", "hypertable_id": 1} | _timescaledb_internal | policy_retention_check (1 row) \set ON_ERROR_STOP 0 @@ -175,9 +175,9 @@ select add_retention_policy('test_table', INTERVAL '3 days'); ERROR: retention policy already exists for hypertable "test_table" \set ON_ERROR_STOP 1 SELECT * FROM _timescaledb_config.bgw_job WHERE proc_name = 'policy_retention' ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------ - 1002 | Retention Policy [1002] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 3 mons", "hypertable_id": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------+-----------------------+------------------------ + 1002 | Retention Policy [1002] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 3 mons", "hypertable_id": 1} | _timescaledb_internal | policy_retention_check (1 row) select remove_retention_policy('test_table'); @@ -214,8 +214,8 @@ select * from _timescaledb_catalog.dimension; (2 rows) SELECT * FROM _timescaledb_config.bgw_job WHERE proc_name = 'policy_retention' ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) select remove_reorder_policy('test_table'); @@ -225,8 +225,8 @@ select remove_reorder_policy('test_table'); (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) select add_retention_policy('test_table', INTERVAL '3 month'); @@ -236,9 +236,9 @@ select add_retention_policy('test_table', INTERVAL '3 month'); (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------ - 1003 | Retention Policy [1003] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 3 mons", "hypertable_id": 1} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------+-----------------------+------------------------ + 1003 | Retention Policy [1003] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 1 | {"drop_after": "@ 3 mons", "hypertable_id": 1} | _timescaledb_internal | policy_retention_check (1 row) select remove_retention_policy('test_table'); @@ -248,8 +248,8 @@ select remove_retention_policy('test_table'); (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) select add_retention_policy('test_table_int', 1); @@ -259,9 +259,9 @@ select add_retention_policy('test_table_int', 1); (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+--------------------------------------- - 1004 | Retention Policy [1004] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 2 | {"drop_after": 1, "hypertable_id": 2} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+---------------------------------------+-----------------------+------------------------ + 1004 | Retention Policy [1004] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 2 | {"drop_after": 1, "hypertable_id": 2} | _timescaledb_internal | policy_retention_check (1 row) -- Should not add new policy with different parameters @@ -279,8 +279,8 @@ select remove_retention_policy('test_table_int'); (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) -- Make sure remove works when there's nothing to remove @@ -318,8 +318,8 @@ ERROR: OID 2 does not refer to a table \set ON_ERROR_STOP 1 -- Now make sure policy args have correct job deletion dependency SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) select add_retention_policy('test_table', INTERVAL '2 month') as job_id \gset @@ -436,24 +436,24 @@ select add_retention_policy('test_table2', INTERVAL '1 days'); (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------ - 1009 | Retention Policy [1009] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 4 | {"drop_after": "@ 2 days", "hypertable_id": 4} - 1010 | Retention Policy [1010] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 5 | {"drop_after": "@ 1 day", "hypertable_id": 5} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+------------------------------------------------+-----------------------+------------------------ + 1009 | Retention Policy [1009] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 4 | {"drop_after": "@ 2 days", "hypertable_id": 4} | _timescaledb_internal | policy_retention_check + 1010 | Retention Policy [1010] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 5 | {"drop_after": "@ 1 day", "hypertable_id": 5} | _timescaledb_internal | policy_retention_check (2 rows) DROP TABLE test_table; DROP TABLE test_table_int; SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+----------------------------------------------- - 1010 | Retention Policy [1010] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 5 | {"drop_after": "@ 1 day", "hypertable_id": 5} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+-----------------------------------------------+-----------------------+------------------------ + 1010 | Retention Policy [1010] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 5 | {"drop_after": "@ 1 day", "hypertable_id": 5} | _timescaledb_internal | policy_retention_check (1 row) DROP TABLE test_table2; SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) -- Now test chunk_stat insertion @@ -512,9 +512,9 @@ select job_id,chunk_id,num_times_job_run from _timescaledb_internal.bgw_policy_c (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+---------------------------------------------------- - 1011 | Reorder Policy [1011] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 6 | {"index_name": "second_index", "hypertable_id": 6} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+----------------------------------------------------+-----------------------+---------------------- + 1011 | Reorder Policy [1011] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 6 | {"index_name": "second_index", "hypertable_id": 6} | _timescaledb_internal | policy_reorder_check (1 row) -- Deleting a chunk that has nothing to do with the job should do nothing @@ -528,9 +528,9 @@ select job_id,chunk_id,num_times_job_run from _timescaledb_internal.bgw_policy_c (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+---------------------------------------------------- - 1011 | Reorder Policy [1011] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 6 | {"index_name": "second_index", "hypertable_id": 6} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+----------------------------------------------------+-----------------------+---------------------- + 1011 | Reorder Policy [1011] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 6 | {"index_name": "second_index", "hypertable_id": 6} | _timescaledb_internal | policy_reorder_check (1 row) -- Dropping the hypertable should drop the chunk, which should drop the reorder policy @@ -541,8 +541,8 @@ select job_id,chunk_id,num_times_job_run from _timescaledb_internal.bgw_policy_c (0 rows) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) -- Now check dropping a job will drop the chunk_stat row @@ -574,10 +574,10 @@ select job_id,chunk_id,num_times_job_run from _timescaledb_internal.bgw_policy_c (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+----------------------------------------------------------- - 1012 | Reorder Policy [1012] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 7 | {"index_name": "test_table_time_idx", "hypertable_id": 7} - 1013 | Retention Policy [1013] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 7 | {"drop_after": "@ 2 days", "hypertable_id": 7} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-------------------------+-------------------+-------------+-------------+--------------+-----------------------+------------------+-------------------+-----------+---------------+-----------------------------------------------------------+-----------------------+------------------------ + 1012 | Reorder Policy [1012] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 7 | {"index_name": "test_table_time_idx", "hypertable_id": 7} | _timescaledb_internal | policy_reorder_check + 1013 | Retention Policy [1013] | @ 1 day | @ 5 mins | -1 | @ 5 mins | _timescaledb_internal | policy_retention | default_perm_user | t | 7 | {"drop_after": "@ 2 days", "hypertable_id": 7} | _timescaledb_internal | policy_retention_check (2 rows) -- Dropping the drop_chunks job should not affect the chunk_stats row @@ -594,9 +594,9 @@ select job_id,chunk_id,num_times_job_run from _timescaledb_internal.bgw_policy_c (1 row) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+----------------------------------------------------------- - 1012 | Reorder Policy [1012] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 7 | {"index_name": "test_table_time_idx", "hypertable_id": 7} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+-----------------------------------------------------------+-----------------------+---------------------- + 1012 | Reorder Policy [1012] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 7 | {"index_name": "test_table_time_idx", "hypertable_id": 7} | _timescaledb_internal | policy_reorder_check (1 row) select remove_reorder_policy('test_table'); @@ -612,16 +612,16 @@ select job_id,chunk_id,num_times_job_run from _timescaledb_internal.bgw_policy_c (0 rows) SELECT * FROM _timescaledb_config.bgw_job WHERE id >= 1000 ORDER BY id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+-------- + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +----+------------------+-------------------+-------------+-------------+--------------+-------------+-----------+-------+-----------+---------------+--------+--------------+------------ (0 rows) -- Now test if alter_job works select add_reorder_policy('test_table', 'test_table_time_idx') as job_id \gset select * from _timescaledb_config.bgw_job where id=:job_id; - id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config -------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+----------------------------------------------------------- - 1014 | Reorder Policy [1014] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 7 | {"index_name": "test_table_time_idx", "hypertable_id": 7} + id | application_name | schedule_interval | max_runtime | max_retries | retry_period | proc_schema | proc_name | owner | scheduled | hypertable_id | config | check_schema | check_name +------+-----------------------+-------------------+-------------+-------------+--------------+-----------------------+----------------+-------------------+-----------+---------------+-----------------------------------------------------------+-----------------------+---------------------- + 1014 | Reorder Policy [1014] | @ 84 hours | @ 0 | -1 | @ 5 mins | _timescaledb_internal | policy_reorder | default_perm_user | t | 7 | {"index_name": "test_table_time_idx", "hypertable_id": 7} | _timescaledb_internal | policy_reorder_check (1 row) -- No change diff --git a/tsl/test/sql/cagg_errors.sql b/tsl/test/sql/cagg_errors.sql index 6c65e1c0454..3072f5f72ce 100644 --- a/tsl/test/sql/cagg_errors.sql +++ b/tsl/test/sql/cagg_errors.sql @@ -434,16 +434,19 @@ GROUP BY 1 WITH NO DATA; SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": null}'); -- ... this one because it has a bad value for start_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": "1 fortnight", "mat_hypertable_id": 11}'); -- ... this one because it has a bad value for end_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": "chicken", "start_offset": null, "mat_hypertable_id": 11}'); \set ON_ERROR_STOP 1 diff --git a/tsl/test/sql/cagg_errors_deprecated.sql b/tsl/test/sql/cagg_errors_deprecated.sql index 8fb799c0483..062980663d3 100644 --- a/tsl/test/sql/cagg_errors_deprecated.sql +++ b/tsl/test/sql/cagg_errors_deprecated.sql @@ -490,16 +490,19 @@ GROUP BY 1 WITH NO DATA; SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": null}'); -- ... this one because it has a bad value for start_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": null, "start_offset": "1 fortnight", "mat_hypertable_id": 11}'); -- ... this one because it has a bad value for end_offset SELECT add_job( '_timescaledb_internal.policy_refresh_continuous_aggregate'::regproc, '1 hour'::interval, + check_config => '_timescaledb_internal.policy_check_continuous_aggregate'::regproc, config => '{"end_offset": "chicken", "start_offset": null, "mat_hypertable_id": 11}'); \set ON_ERROR_STOP 1