From 61a12b96344636cef8fc403a7237a2155a20ea3e Mon Sep 17 00:00:00 2001 From: Jan Nidzwetzki Date: Fri, 8 Mar 2024 10:17:48 +0100 Subject: [PATCH] Remove autovacuum setting from compressed chunks In old TSDB versions, we disabled autovacuum for compressed chunks to keep the statistics. However, this restriction was removed in #5118, but no migration was performed to reset the custom autovacuum for existing chunks. --- .unreleased/bugfix_6752 | 1 + sql/updates/latest-dev.sql | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .unreleased/bugfix_6752 diff --git a/.unreleased/bugfix_6752 b/.unreleased/bugfix_6752 new file mode 100644 index 00000000000..a17b3cc0629 --- /dev/null +++ b/.unreleased/bugfix_6752 @@ -0,0 +1 @@ +Fixes: #6752 Remove custom autovacuum setting from compressed chunks diff --git a/sql/updates/latest-dev.sql b/sql/updates/latest-dev.sql index 6ba3ab3ad6e..caf95e42211 100644 --- a/sql/updates/latest-dev.sql +++ b/sql/updates/latest-dev.sql @@ -161,4 +161,20 @@ DROP FUNCTION IF EXISTS _timescaledb_functions.get_chunk_colstats; DROP FUNCTION IF EXISTS _timescaledb_internal.get_chunk_relstats; DROP FUNCTION IF EXISTS _timescaledb_internal.get_chunk_colstats; - +-- In older TSDB versions, we disabled autovacuum for compressed chunks +-- to keep the statistics. However, this restriction was removed in +-- #5118 but no migration was performed to remove the custom +-- autovacuum setting for existing chunks. +DO $$ +DECLARE + chunk regclass; +BEGIN + FOR chunk IN + SELECT format('%I.%I', schema_name, table_name)::regclass + FROM _timescaledb_catalog.chunk WHERE compressed_chunk_id IS NOT NULL + LOOP + EXECUTE format('ALTER TABLE %s RESET (autovacuum_enabled);', chunk::text); + END LOOP; +END +$$; +DO