Add per-catalog active partition count limit#89
Merged
Conversation
Introduce `max_active_partitions` config (default 4096) enforced alongside the existing `max_partition_bytes` limit in `prune_topics`. When the number of active (in-memory, writable) partitions across the catalog exceeds the limit, the oldest active partitions are closed until the count is back within bounds, mirroring the byte-based pruning. Also fix the pruning `ages` map, which was keyed solely on segment end time: partitions sharing an end time collided and overwrote each other, hiding them from both the byte and active-count limits. The key now includes the topic and partition names as tiebreakers. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dcvvv5f1pihsE6gDaETRid
Reconcile classified segments using the in-memory `sealed_ix` watermark, reading it via `get_topic`/`get_partition` — which lazily *loads* the partition. A freshly loaded partition reports `sealed_ix == None`, so every one of its on-disk segments fell into the informational "active" bucket. This inflated the reported `active_segments` count: each cold or evicted partition contributed all of its segments, even though a closed partition's tail is immutable (a reopen begins a brand-new segment at `max_segment + 1`, so nothing ever appends to the persisted tail again). Classify each partition without loading it: a non-resident partition is quiescent and all its persisted segments are sealed, while a resident partition keeps the conservative watermark semantics so its live active tail (and any in-flight roll) still lands in the active bucket. Add a non-loading `Catalog::resident_sealed_ix` / `Topic::resident_sealed_ix` lookup and a `SealStatus` classification for the pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dcvvv5f1pihsE6gDaETRid
a97ef7f to
2ad79e9
Compare
imp
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce
max_active_partitionsconfig (default 256) enforced alongside the existingmax_partition_byteslimit inprune_topics. When the number of active (in-memory, writable) partitions across the catalog exceeds the limit, the oldest active partitions are closed until the count is back within bounds, mirroring the byte-based pruning.Also fix the pruning
agesmap, which was keyed solely on segment end time: partitions sharing an end time collided and overwrote each other, hiding them from both the byte and active-count limits. The key now includes the topic and partition names as tiebreakers.Claude-Session: https://claude.ai/code/session_01Dcvvv5f1pihsE6gDaETRid