I’m getting the same error as this guy but in a different situation.
I have a procedure that dynamically creates the text of a query into a text variable that then it gets EXECUTED. That query does three things:
CREATE MATERIALIZED VIEW … WITH (timescaledb.continuous) AS SELECT … WITH NO DATA;
CALL refresh_continuous_aggregate(…
SELECT add_continuous_aggregate_policy(…
I make the creation and population of the continuous aggregate two separate steps because if not postgresql complains that ERROR: CREATE MATERIALIZED VIEW ... WITH DATA cannot be executed from a function. But when executing it in two separate steps, timescaledb says the following:
ERROR: portal snapshots (1) did not account for all active snapshots (2)
If I remove CALL refresh_continuous_aggregate(... then it works, so it’s related to the populating/refresh step.
I have seen that if I create a separeted procedure to only do CALL refresh_continuous_aggregate(... then if I execute them inside the procedure as static queries they work. If I generate the refresh queries dynamically (that’s what I want) then it fails with the same exact error.
FOREACH time_unit IN ARRAY time_units LOOP
refresh_query = format($$CALL refresh_continuous_aggregate('xxx_%s', NULL, INTERVAL '1 %s');$$, time_unit, time_unit);
EXECUTE refresh_query;
END LOOP;
Also in a unrelated issue, the month continous aggregate can’t be updated with an open interval. This works: CALL refresh_continuous_aggregate('xxx_month', '2017-01-01', INTERVAL '1 mon');
This returns “ERROR: timestamp out of range”: CALL refresh_continuous_aggregate('xxx_month', NULL, INTERVAL '1 mon');
Probably it’s a bug! I’m not sure if it’s related to wrapping things in a transaction or not. Feel free to create a new issue for each case as they’re isolated examples and let’s confirm it with the core team.