[Improve][connector-starrocks] Improved starrocks source enumerator splits allocation algorithm for subtasks#10867
Open
JeremyXin wants to merge 2 commits into
Open
Conversation
DanielLeens
suggested changes
May 11, 2026
Contributor
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the contribution. I pulled the latest head locally and reviewed the real StarRocks source enumerator lifecycle instead of only the helper diff.
What this PR fixes
- User pain: the current owner calculation can leave StarRocks splits uneven across readers.
- Fix approach: sort split ids first, then assign them round-robin.
- In one sentence: the goal makes sense, but the current implementation breaks both the recovery contract and the real multi-table runtime path.
Runtime path I checked
normal startup
-> run() [StartRocksSourceSplitEnumerator.java:81-94]
-> poll one table
-> getStarRocksSourceSplit(table) [193-201]
-> addPendingSplit(newSplits) [151-164]
-> assignSplit(readers) [167-190]
reader recovery
-> addSplitsBack(splits, subtaskId) [102-106]
-> addPendingSplit(splits)
-> assignSplit(subtaskId)
Problem 1: the returned-split recovery path is no longer correct
- Location:
StartRocksSourceSplitEnumerator.java:102-106, 151-164 - Why this is a problem: before this change,
addSplitsBack()could recompute the same owner fromsplitId.hashCode()and then immediately assign back to the recoveringsubtaskId. After the change, owner selection depends on the local round-robin order inside the currentaddPendingSplit()call. That means a split returned by reader 2 can now be put into reader 0's bucket, whileassignSplit(Collections.singletonList(subtaskId))still only tries to send work back to reader 2. - Risk: the split can remain stranded in
pendingSplit, so the recovery path can stall even though the source still has unassigned work. - Suggested fix:
- Option A: keep
addSplitsBack()pinned to the originalsubtaskIdinstead of reusing the new owner calculation. - Option B: if you want re-computed ownership, it still needs to be derived from a stable split identity, not from the per-call round-robin position.
- Option A: keep
- Severity: high
Problem 2: the new balancing claim does not hold on the real multi-table path
- Location:
StartRocksSourceSplitEnumerator.java:81-94, 151-164 - Why this is a problem:
run()processes one table at a time, butassignCountis reset to0on everyaddPendingSplit()call. So if a table produces a single split, that split always starts again from reader 0. With many small tables, the normal path still concentrates work on low-number readers. - Risk: the PR can replace one skew mode with another, especially for common small-table workloads.
- Suggested fix:
- Option A: keep
assignCountmonotonic across the whole enumeration cycle. - Option B: aggregate all generated splits first, then do one global round-robin pass.
- Option A: keep
- Severity: high
Tests
- The new test only exercises one synthetic single-batch call to the private
addPendingSplit()helper (StarRocksSourceSplitEnumeratorTest.java:40-60). It does not cover the actualrun()batching behavior or theaddSplitsBack()recovery path, which is exactly where the regressions are.
Conclusion: merge after fixes
- Blocking items
- Problem 1: recovery can strand returned splits in the wrong reader bucket.
- Problem 2: the real multi-table path still does not produce the balanced behavior the PR is aiming for.
- Suggested follow-up
- Please add lifecycle-level coverage for both
run()andaddSplitsBack()once the logic is adjusted.
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 of this pull request
Similar to pr #9108, improving starrocks source enumerator splits allocation algorithm for subtasks and add UT.
Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide
incompatible-changes.mdto describe the incompatibility caused by this PR.