Skip to content

feat: check fails when a hypertable keeps too many chunks or declares no retention - #40

Open
systemfsoftware-bot wants to merge 3 commits into
feat-bounded-readsfrom
feat-chunk-count-check
Open

systemfsoftware-bot wants to merge 3 commits into
feat-bounded-readsfrom
feat-chunk-count-check

Conversation

@systemfsoftware-bot

Copy link
Copy Markdown
Contributor

Stacked on #39 (it reuses that PR's interval reader); retarget to main when #39 merges.

timescale-drizzle check now also reads the hypertable declarations and fails when one can keep too many chunks. Each chunk and its indexes cost a lock in any query that cannot exclude it.

  • Steady-state chunk count = ceil(dropAfter / chunkTimeInterval) (7 days when unset), times numberPartitions for a space partition. dropCreatedBefore counts the same way. Limit 500, --max-chunks <n> to change it.
  • No retention fails unless the table declares retention: 'unbounded' (which creates no policy).
  • retention: 'unbounded' plus expectedHistory: '3 years': check counts ceil(expectedHistory / chunkTimeInterval) against the limit. expectedHistory is declared, not measured, and check is the only reader. Without it the table passes with a note, because no count can be computed without guessing.
  • expectedHistory without 'unbounded' is a declaration error.

Run on six declarations (scratch script, not in the diff): 1-day interval with 10 years retention reports 3650 chunks; 14 days over 90 days passes; no retention fails; unbounded with no history gives the note; unbounded 1-day over 3 years reports 1095; 30-day over 3 years passes.

Typecheck, lint and format pass. No tests added.

Limits stated in the README: months count 30 days and years 365; dropCreatedBefore follows chunk creation time, so a backfill keeps more than the formula says; compressed-chunk tables are not counted; continuous aggregates are not checked.

Gemini review: space partitions omitted (fixed); no guard on the limit passed to the exported function (fixed). Not taken: conservative month/year bounds, a scheduleInterval + 1 boundary chunk (the formula is the one specified), columnstore doubling. Its claim that dropAfter plus dropCreatedBefore is accepted is wrong: readRetention already rejects it.

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.

1 participant