[bugfix] Fix instance partition import rebalance for COMPLETED segments#18635
Open
shauryachats wants to merge 3 commits into
Open
[bugfix] Fix instance partition import rebalance for COMPLETED segments#18635shauryachats wants to merge 3 commits into
shauryachats wants to merge 3 commits into
Conversation
When a table imports instance partitions from another table via instancePartitionsMap, shouldRelocateCompletedSegments() only checked instanceAssignmentConfigMap and missed the pre-configured COMPLETED instance partitions. This caused COMPLETED segments to never be relocated during rebalance, leaving them pinned to a single server per partition instead of being distributed by the ReplicaGroupSegmentAssignmentStrategy. The fix adds a check for pre-configured instance partitions (hasPreConfiguredInstancePartitions) so that imported COMPLETED instance partitions are properly loaded and used during rebalance. Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise shouldRelocateCompletedSegments and buildRebalanceInstancePartitionsMap instead of passing COMPLETED IPs directly to rebalanceTable; assert buggy path when COMPLETED IPs are omitted. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18635 +/- ##
===========================================
Coverage 64.45% 64.45%
- Complexity 1137 1282 +145
===========================================
Files 3337 3352 +15
Lines 206067 207172 +1105
Branches 32127 32349 +222
===========================================
+ Hits 132816 133536 +720
- Misses 62599 62902 +303
- Partials 10652 10734 +82
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
Tables that import instance partitions from another table via
instancePartitionsMap(without a separateinstanceAssignmentConfigMapentry for COMPLETED) were broken during rebalance.TableRebalancer.getInstancePartitionsMap()only loads COMPLETED instance partitions whenInstanceAssignmentConfigUtils.shouldRelocateCompletedSegments()returns true - but that method only looked atinstanceAssignmentConfigMapand tenant tag overrides, not imported partitions ininstancePartitionsMap.As a result, rebalance passed only CONSUMING instance partitions into segment assignment. Completed segments stayed pinned to one server per stream partition instead of spreading across all servers in each instance partition under
ReplicaGroupSegmentAssignmentStrategy(e.g. 16 servers used instead of 64 in the prod layout).The fix adds a check for
InstancePartitionsUtils.hasPreConfiguredInstancePartitions(tableConfig, COMPLETED)so imported COMPLETED partitions trigger relocation the same way as explicitly configured assignment.Test
RealtimeReplicaGroupSegmentAssignmentTest#testImportedInstancePartitionsWithMultipleServersPerPartitionmirrors the TableRebalancer path: it builds the rebalanceinstancePartitionsMapviashouldRelocateCompletedSegments(tableConfig)rather than always injecting COMPLETED IPs. It asserts the pre-fix behavior when COMPLETED IPs are omitted, and that with the fix all servers receive completed segments (including bootstrap rebalance).