[Core] Add compaction.task-threads for multi-thread async compaction per write subtask - #10133
jacklong319 wants to merge 6 commits into
Conversation
|
The linked production issue provides a strong end-to-end case for cross-bucket compaction parallelism (reported DV read lag improved from ~40 min at 1 thread to ~8 min at 3). I traced the executor routing and the per-bucket compact managers’ Merge blockers / production follow-up:
The feature has clear value, but the current head is not ready to merge. |
(Same body bullets as above.) Related to apache#10132
JingsongLi
left a comment
There was a problem hiding this comment.
Reviewed head 072f895 for production use. The end-to-end value is clear: allowing buckets within one long-lived Flink write subtask to compact concurrently can reduce the MOW/DV visibility lag described in #10132. The update addresses the previous feedback on invalid values, documentation, focused executor tests, and Spotless. Local JDK 8 verification passed: the three new test classes 10/10; existing MergeTreeCompactManagerTest, KeyValueFileStoreWriteTest, and BucketedAppendFileStoreWriteTest 26/26; and ordinary mvn -pl paimon-api,paimon-core -DskipTests compile including Spotless. Current full CI is still running.
P1 — retire compaction timers when PER_BUCKET workers are retired. AbstractFileStoreWrite.releaseCompactionExecutor shuts down and removes each bucket executor, but CompactionMetrics.ReporterImpl.getCompactTimer() caches a CompactTimer by thread ID in compactTimers and never removes that entry; ReporterImpl.unregister() removes only the reporter. In a long-lived Flink subtask with changing active partitions/buckets, each replacement worker has a new thread ID. The compactionThreadBusy gauge scans every historical timer, so both retained state and scrape cost grow with total buckets ever compacted, even after their writers are gone. I reproduced this with 32 sequential single-thread workers: after shutting each down and unregistering its reporter, the timer map still held all 32 entries (expected 0). The temporary probe was removed from the review checkout. Please bound or retire these timers on worker shutdown and add a churn regression test for PER_BUCKET; the current routing tests only check executor removal.
This is a feature-specific blocker for the new -1 mode. The default single-thread path and fixed-size pool do not create the same unbounded worker churn.
Thanks @JingsongLi — agreed on the P1 for PER_BUCKET timer retention. I’ll fix timer retirement on worker shutdown, add the churn regression test, and update the PR soon. |
Release CompactTimer entries on reporter unregister with ref-counting for shared compaction threads. Add churn regression tests mimicking PER_BUCKET worker rotation. Related to apache#10132
Purpose
Linked issue: close #10132
Today each Flink write subtask uses one shared async compaction thread for all
(partition, bucket)writers. Under peak load, compaction falls behind; in Deletion Vectors (MOW) mode, delayed L0 compaction hurts read freshness (see #10132).This PR adds table option
compaction.task-threadsto run parallel async compaction across buckets within the same write subtask, while compaction for the same bucket remains serialized.Semantics:
1(default):SINGLE— unchanged behavior.N > 1:FIXED_POOL— N threads shared by buckets in the subtask.-1:PER_BUCKET— one thread per active(partition, bucket)writer (higher memory use).Changes:
CompactionTaskExecutorModeandCoreOptions.COMPACTION_TASK_THREADS.AbstractFileStoreWrite.compactExecutor(partition, bucket); release per-bucket executors on writer cleanup where applicable.1; no storage format change.Tests
mvn -pl paimon-api,paimon-core -am -Pfast-build test