mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 02:53:51 +08:00
Fix segfault in job_config_check for cagg
When mat_hypertable_id in the config JSON of job was altered to an invalid hypertable id the alter_job would segfault. Fixes #2980
This commit is contained in:
parent
6f4cfc8886
commit
a947b7e0df
@ -341,6 +341,13 @@ policy_refresh_cagg_read_and_validate_config(Jsonb *config, PolicyContinuousAggD
|
||||
|
||||
materialization_id = policy_continuous_aggregate_get_mat_hypertable_id(config);
|
||||
mat_ht = ts_hypertable_get_by_id(materialization_id);
|
||||
|
||||
if (!mat_ht)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("configuration materialization hypertable id %d not found",
|
||||
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);
|
||||
|
@ -574,3 +574,18 @@ DROP TABLE measurements CASCADE;
|
||||
NOTICE: drop cascades to 3 other objects
|
||||
DROP TABLE conditions CASCADE;
|
||||
NOTICE: drop cascades to 3 other objects
|
||||
-- test handling of invalid mat_hypertable_id
|
||||
create table i2980(time timestamptz not null);
|
||||
select create_hypertable('i2980','time');
|
||||
create_hypertable
|
||||
---------------------
|
||||
(12,public,i2980,t)
|
||||
(1 row)
|
||||
|
||||
create materialized view i2980_cagg with (timescaledb.continuous) AS SELECT time_bucket('1h',time), avg(7) FROM i2980 GROUP BY 1;
|
||||
NOTICE: continuous aggregate "i2980_cagg" is already up-to-date
|
||||
select add_continuous_aggregate_policy('i2980_cagg',NULL,NULL,'4h') AS job_id \gset
|
||||
\set ON_ERROR_STOP 0
|
||||
select alter_job(:job_id,config:='{"end_offset": null, "start_offset": null, "mat_hypertable_id": 1000}');
|
||||
ERROR: configuration materialization hypertable id 1000 not found
|
||||
\set ON_ERROR_STOP 1
|
||||
|
@ -529,3 +529,13 @@ SELECT alter_job(:job_id,
|
||||
|
||||
DROP TABLE measurements CASCADE;
|
||||
DROP TABLE conditions CASCADE;
|
||||
|
||||
-- test handling of invalid mat_hypertable_id
|
||||
create table i2980(time timestamptz not null);
|
||||
select create_hypertable('i2980','time');
|
||||
create materialized view i2980_cagg with (timescaledb.continuous) AS SELECT time_bucket('1h',time), avg(7) FROM i2980 GROUP BY 1;
|
||||
select add_continuous_aggregate_policy('i2980_cagg',NULL,NULL,'4h') AS job_id \gset
|
||||
\set ON_ERROR_STOP 0
|
||||
select alter_job(:job_id,config:='{"end_offset": null, "start_offset": null, "mat_hypertable_id": 1000}');
|
||||
\set ON_ERROR_STOP 1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user