Skip to content

feat(compaction): wire real CompactManager into MergeTreeWriter for key-table compaction#198

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/review-pr-195
Closed

feat(compaction): wire real CompactManager into MergeTreeWriter for key-table compaction#198
Copilot wants to merge 1 commit intomainfrom
copilot/review-pr-195

Conversation

Copy link

Copilot AI commented Mar 25, 2026

Prior to this change, MergeTreeWriter held no CompactManager and its Compact()/Sync()/CompactNotCompleted() methods returned NotImplemented. Key-value tables had no compaction at the framework layer.

Core new components

  • MergeTreeCompactManager — orchestrates compaction for KV tables: picks units via CompactStrategy, submits MergeTreeCompactTask to executor, applies results back to Levels
  • MergeTreeCompactTask — handles the rewrite-vs-upgrade decision per section of sorted runs; uses IntervalPartition to detect overlapping files; supports DeletionFileSupplier for DV-enabled tables
  • FileRewriteCompactTask — simpler per-file rewrite task for lookup-mode full compaction
  • CancellationController — atomic bool wrapped in a shared object; passed into all rewriters so in-flight compaction can be cancelled on Close()

Interface changes

  • CompactManager::AddNewFile() now returns Status (was void); all implementors updated
  • MergeTreeWriter ctor gains a CompactManager parameter; Compact/Sync are now real implementations that flush buffered data, trigger compaction, and sync results
  • LookupLevels::levels_ promoted from unique_ptr to shared_ptr so it can be shared with MergeTreeCompactManager
  • MergeTreeCompactRewriter and subclasses gain a CancellationController parameter
  • WriteContext / AbstractFileStoreWrite / KeyValueFileStoreWrite gain IOManager and a separate key_comparator_for_compact (view-free, for min/max key comparison in Levels)

New config options

compaction.max-size-amplification-percent  (default 200)
compaction.size-ratio                      (default 1)
num-sorted-run.compaction-trigger          (default 5)
num-sorted-run.stop-trigger                (default trigger+3)
num-levels                                 (no default)
compaction.force-up-level-0               (default false)
lookup-compact                             (RADICAL | GENTLE, default RADICAL)
lookup-compact.max-interval               (default 10)

Tests

  • MergeTreeCompactManagerTest — 13 unit tests covering level routing, full compaction, stop-trigger enforcement, and reentrant-full-compaction rejection
  • KeyValueCompactionInteTest — integration tests for IO-exception recovery and stream-write full compaction
  • Existing MergeTreeWriterTest / LookupMergeTreeCompactRewriterTest updated to pass NoopCompactManager where the new ctor requires a manager

TODO: lookup-mode compaction framework is not yet wired (CreateLookupRewriter stubs exist but the full path is incomplete).


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Review changes made in PR #195 feat(compaction): wire real CompactManager into MergeTreeWriter for key-table compaction Mar 25, 2026
Copilot AI requested a review from zjw1111 March 25, 2026 10:34
@zjw1111 zjw1111 closed this Mar 25, 2026
@alibaba alibaba locked as off-topic and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants