Skip to content

Conversation

@kpan2034
Copy link
Member

@kpan2034 kpan2034 commented Sep 8, 2025

Downgrading from 2.22.0 is blocked in certain cases due to unrefreshed CAggs. This provides a workaround, if CAggs cannot be refreshed before downgrading.

Downgrading from 2.22.0 is blocked in certain cases due to
unrefreshed CAggs. This provides a workaround, if CAggs cannot be
refreshed before downgrading.
@kpan2034 kpan2034 self-assigned this Sep 8, 2025
ORDER BY sr.materialization_id
LOOP
RAISE NOTICE 'force refreshing %s: start:%s end:%s', range_record.cagg_name, _timescaledb_functions.to_timestamp(range_record.lowest), _timescaledb_functions.to_timestamp(range_record.greatest);
CALL refresh_continuous_aggregate(range_record.cagg_name, _timescaledb_functions.to_timestamp(range_record.lowest), _timescaledb_functions.to_timestamp(range_record.greatest), force => true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also consider integer time dimension

Comment on lines +16 to +19
END LOOP;
END $$;

DROP TABLE _timescaledb_internal.saved_ranges;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
END LOOP;
END $$;
DROP TABLE _timescaledb_internal.saved_ranges;
END LOOP;
DROP TABLE _timescaledb_internal.saved_ranges;
END $$;

I think it must be part of the anonymous transaction.

DO $$
DECLARE
range_record RECORD;
BEGIN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here you can check for the existance of the stating table and raise an exception that the table don't exists so probably the script was already executed.

Comment on lines +3 to +5
SELECT *
INTO _timescaledb_internal.saved_ranges
FROM _timescaledb_catalog.continuous_aggs_materialization_ranges;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SELECT *
INTO _timescaledb_internal.saved_ranges
FROM _timescaledb_catalog.continuous_aggs_materialization_ranges;
CREATE TABLE _timescaledb_internal.saved_ranges AS
SELECT *
FROM _timescaledb_catalog.continuous_aggs_materialization_ranges
ORDER BY materialization_id, lowest_modified_value;

Nit. IMHO using CREATE TABLE instead of SELECT INTO express better the intention.

\set ON_ERROR_STOP ON

SELECT *
INTO _timescaledb_internal.saved_ranges
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also maybe continuous_aggs_materialization_ranges_before_downgrade_2_22_0 can be a better name to also express the intention.

I think it should be saved it in the public schema instead cause is preferred to let the extension update/downgrade script mess with our internal schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants