Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit b909a82

Browse files
committed
Fix skipping compression of first to last chunk
Due to a bug in logic, we were skipping compression of the first to last chunk which ended over an hour ago from current time. This was causing to have one more chunk per metric uncompressed, causing us to use more storage than necessary.
1 parent c6d6feb commit b909a82

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ We use the following categories for changes:
1919

2020
### Fixed
2121
- Fix broken `promscale_packager` telemetry field for docker envs [#1077]
22+
- Fix compression of old chunks thus reducing storage requirements [#1081]
2223

2324
## [0.8.0] - 2022-01-18
2425

pkg/migrations/migration_files_generated.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/migrations/sql/idempotent/base.sql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,21 +2921,22 @@ BEGIN
29212921
DECLARE
29222922
chunk_schema_name name;
29232923
chunk_table_name name;
2924+
chunk_range_end timestamptz;
29242925
chunk_num INT;
29252926
BEGIN
2926-
FOR chunk_schema_name, chunk_table_name, chunk_num IN
2927+
FOR chunk_schema_name, chunk_table_name, chunk_range_end, chunk_num IN
29272928
SELECT
29282929
chunk_schema,
29292930
chunk_name,
2931+
range_end,
29302932
row_number() OVER (ORDER BY range_end DESC)
29312933
FROM timescaledb_information.chunks
29322934
WHERE hypertable_schema = 'SCHEMA_DATA'
29332935
AND hypertable_name = metric_table
29342936
AND NOT is_compressed
2935-
AND range_end <= compress_before
29362937
ORDER BY range_end ASC
29372938
LOOP
2938-
CONTINUE WHEN chunk_num <= 1;
2939+
CONTINUE WHEN chunk_num <= 1 OR chunk_range_end > compress_before;
29392940
PERFORM SCHEMA_CATALOG.compress_chunk_for_metric(metric_table, chunk_schema_name, chunk_table_name);
29402941
COMMIT;
29412942
END LOOP;

0 commit comments

Comments
 (0)