Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: if_not_exists optional parameter for add_continuous_aggregate_policy() doesn't return notice if policy already exists #5688

Closed
ccrotty opened this issue May 15, 2023 · 5 comments · Fixed by #6531
Assignees
Labels

Comments

@ccrotty
Copy link

ccrotty commented May 15, 2023

What type of bug is this?

Unexpected error

What subsystems and features are affected?

Continuous aggregate, Policy

What happened?

Executing the following when the continuous aggregate policy already exists returns an error instead of the expected NOTICE response:

SELECT add_continuous_aggregate_policy('tsmetrics.test_agg_mv', start_offset => null, end_offset => INTERVAL '1 hour', schedule_interval => INTERVAL '1 hour', if_not_exists => TRUE);

Error response was
ERROR: could not find start_offset in config for job SQL state: XX000

TimescaleDB version affected

2.9.3

PostgreSQL version used

14.6

What operating system did you use?

x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit

What installation method did you use?

Docker

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

ERROR:  could not find start_offset in config for job  SQL state: XX000

How can we reproduce the bug?

Create a continuous aggregate policy request with add_continuous_aggregate_policy() including the if_not_exists optional parameter.  Then run the same request after it has been created.
@ccrotty ccrotty added the bug label May 15, 2023
@shhnwz shhnwz self-assigned this May 16, 2023
@shhnwz
Copy link
Contributor

shhnwz commented May 17, 2023

Hi @ccrotty ,

Thanks for reporting this issue!
We are able to reproduce it in-house and its a bug. This issue only shows up when start_offset or end_offset is set to null.

Steps to reproduce:

CREATE TABLE int_tab (a integer, b integer, c integer);
SELECT table_name FROM create_hypertable('int_tab', 'a', chunk_time_interval=> 10);

INSERT INTO int_tab VALUES( 3 , 16 , 20);
INSERT INTO int_tab VALUES( 1 , 10 , 20);
INSERT INTO int_tab VALUES( 1 , 11 , 20);
INSERT INTO int_tab VALUES( 1 , 12 , 20);
INSERT INTO int_tab VALUES( 1 , 13 , 20);
INSERT INTO int_tab VALUES( 1 , 14 , 20);
INSERT INTO int_tab VALUES( 2 , 14 , 20);
INSERT INTO int_tab VALUES( 2 , 15 , 20);
INSERT INTO int_tab VALUES( 2 , 16 , 20);

CREATE OR REPLACE FUNCTION integer_now_int_tab() returns int LANGUAGE SQL STABLE as $$ SELECT coalesce(max(a), 0) FROM int_tab $$; 
SELECT set_integer_now_func('int_tab', 'integer_now_int_tab');

CREATE MATERIALIZED VIEW mat_m1( a, countb )
WITH (timescaledb.continuous, timescaledb.materialized_only=true)
as
SELECT a, count(b)
FROM int_tab
GROUP BY time_bucket(1, a), a WITH NO DATA;

SELECT add_continuous_aggregate_policy('mat_m1', start_offset =>10, end_offset =>null, schedule_interval =>'1h'::interval, if_not_exists=>true);

SELECT add_continuous_aggregate_policy('mat_m1', start_offset =>10, end_offset =>null, schedule_interval =>'1h'::interval, if_not_exists=>true);

@Kobus-Smit
Copy link

Hi @shhnwz Any update on this bugfix? We are also experiencing the same issue.

@nicolemoiseyev
Copy link

Also experiencing the same issue. Any update @shhnwz ?

@the4thamigo-uk
Copy link

+1 here also

@mkindahl
Copy link
Contributor

+1 here also

Please upvote the issue if it affects you. It helps with prioritizing bugs.

@shhnwz shhnwz removed their assignment Aug 28, 2023
@konskov konskov self-assigned this Jan 16, 2024
konskov added a commit to konskov/timescaledb that referenced this issue Jan 16, 2024
konskov added a commit to konskov/timescaledb that referenced this issue Jan 16, 2024
konskov added a commit to konskov/timescaledb that referenced this issue Jan 16, 2024
konskov added a commit to konskov/timescaledb that referenced this issue Jan 16, 2024
konskov added a commit to konskov/timescaledb that referenced this issue Jan 17, 2024
github-actions bot pushed a commit that referenced this issue Jan 17, 2024
timescale-automation pushed a commit that referenced this issue Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants