Repository navigation
[core] Compact leftover small files in batch append compaction - #11179
Open
dragonknightk wants to merge 1 commit into
Open
dragonknightk wants to merge 1 commit into
dragonknightk wants to merge 1 commit into
Conversation
### Purpose Closes issue 5130 In batch mode, `AppendCompactCoordinator` now compacts the small files that packing leaves in a partition when there are at least 2 of them. Before this change, such files were compacted only after `COMPACT_AGE` further planning rounds without new files in the partition. A batch compaction stops after planning its last scanned files, so the files left over in that plan stayed uncompacted. - The coordinator already knows the mode from its `isStreaming` constructor argument, which the Flink compact source, the Flink multi-table compact scan and the Spark compact procedure pass. No caller or option changes. - The leftover files form one extra task per partition, even when they are fewer than `compaction.min.file-num`. A single file is not compacted, because rewriting it alone does not reduce the file count. - In batch mode this applies to every plan. When the Flink batch source scans more files than `compaction.file-num-limit`, it plans once per chunk, so a partition can get one leftover task per chunk. - Streaming is unchanged: leftover files still wait for `COMPACT_AGE`. ### Tests - With deletion vectors enabled and `compaction.min.file-num = 3`, 14 files of a third of the target size pack into 2 tasks and leave 2 files. A streaming coordinator plans the 2 tasks and keeps the 2 files. A batch coordinator plans a third task with the 2 files, so the tasks cover all 14 files and nothing is kept. - On a table without deletion vectors, a batch compaction of 2 committed files below `compaction.min.file-num` produces 1 file with both rows, while a streaming coordinator plans nothing. - A batch coordinator does not compact a single file. - The first two scenarios fail on the code before this change. ## AI Disclosure Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission. Signed-off-by: KK <37928252+dragonknightk@users.noreply.github.com>
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.
Purpose
Fixes #5130
In batch mode,
AppendCompactCoordinatornow compacts the small files that packing leaves in a partition when there are at least 2 of them. Before this change, such files were compacted only afterCOMPACT_AGEfurther planning rounds without new files in the partition. A batch compaction stops after planning its last scanned files, so the files left over in that plan stayed uncompacted.isStreamingconstructor argument, which the Flink compact source, the Flink multi-table compact scan and the Spark compact procedure pass. No caller or option changes.compaction.min.file-num. A single file is not compacted, because rewriting it alone does not reduce the file count.compaction.file-num-limit, it plans once per chunk, so a partition can get one leftover task per chunk.COMPACT_AGE.Tests
compaction.min.file-num = 3, 14 files of a third of the target size pack into 2 tasks and leave 2 files. A streaming coordinator plans the 2 tasks and keeps the 2 files. A batch coordinator plans a third task with the 2 files, so the tasks cover all 14 files and nothing is kept.compaction.min.file-numproduces 1 file with both rows, while a streaming coordinator plans nothing.AI Disclosure
Human-led contribution. Grok Bot, working for dragonknightk, assisted with this change, including the code, tests, and description. All submitted content was reviewed by a human before submission. (๑•̀ㅂ•́)و✧