Reputation: 113
I'm trying to create a continuous aggregate view on a hypertable with the policy to refresh the view once a day.
The first time it runs when I create the view was smooth, everything looked fine on Grafana. However, few days later, I found that the background job mostly failed, hence only partial data was aggregated. I tried to find what happened by using the below query but still have absolutely no idea why the job was failed!
SELECT *
FROM timescaledb_information.job_stats
WHERE hypertable_name = '_materialized_hypertable_17';
All I got was
hypertable_schema | hypertable_name | job_id | last_run_started_at | last_successful_finish | last_run_status | job_status | last_run_duration | next_start | total_runs | total_successes | total_failures |
---|---|---|---|---|---|---|---|---|---|---|---|
_timescaledb_internal | _materialized_hypertable_17 | 1013 | 2021-09-05 10:46:11.810904 | 2021-09-01 11:53:41.759126 | Failed | Scheduled | 0 years 0 mons 0 days 0 hours 0 mins 0.022373 secs | 2021-09-08 09:38:41.833277 | 5 | 2 | 3 |
So I tried refreshing the view for those missing buckets. The command was completed within few milliseconds and said the view was already up to date but that was not true! Those partially aggregated buckets were not updated at all.
CALL refresh_continuous_aggregate('daily_system_agg', '2020-09-01', '2020-09-06');
In summary, I got 2 questions:
1. Where can I find more information regarding why the background job was failed?
2. Why the refresh_continuous_aggregate
didn't refresh the data?
Script to create continuous aggregate & policy
CREATE MATERIALIZED VIEW daily_requests_agg
WITH (timescaledb.continuous) AS (
SELECT
time_bucket('1 day', timestamp) as time,
gway,
dest,
api,
count(*) as total
FROM requests
GROUP BY
time,
gway,
dest,
api
);
SELECT add_continuous_aggregate_policy('daily_requests_agg',
start_offset => INTERVAL '1 month',
end_offset => INTERVAL '1 day',
schedule_interval => INTERVAL '1 day');
Upvotes: 1
Views: 610