Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rebalance on upsert table #12054

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

Jackie-Jiang
Copy link
Contributor

#11628 introduced the feature to assign segments for upsert table based on the existing segment assignment. It can potentially cause new segment mis-assigned during rebalance when rebalancer tries to reuse the target assignment.

This PR fixes the issue by always re-calculate target assignment for StrictRealtimeSegmentAssignment, and enhances StrictRealtimeSegmentAssignment to cache the segment partition id to reduce the cost of rebalance.

@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2023

Codecov Report

Attention: 37 lines in your changes are missing coverage. Please review.

Comparison is base (97f8f5f) 61.52% compared to head (41a2c83) 61.65%.

Files Patch % Lines
...nment/segment/StrictRealtimeSegmentAssignment.java 43.75% 23 Missing and 4 partials ⚠️
...ntroller/helix/core/rebalance/TableRebalancer.java 28.57% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12054      +/-   ##
============================================
+ Coverage     61.52%   61.65%   +0.12%     
- Complexity     1152     1153       +1     
============================================
  Files          2386     2386              
  Lines        129565   129579      +14     
  Branches      20053    20056       +3     
============================================
+ Hits          79721    79898     +177     
+ Misses        44026    43868     -158     
+ Partials       5818     5813       -5     
Flag Coverage Δ
custom-integration1 <0.01% <0.00%> (?)
integration <0.01% <0.00%> (ø)
integration1 <0.01% <0.00%> (ø)
integration2 0.00% <0.00%> (ø)
java-11 61.59% <40.32%> (?)
java-21 61.54% <40.32%> (+0.01%) ⬆️
skip-bytebuffers-false 61.61% <40.32%> (+0.11%) ⬆️
skip-bytebuffers-true 61.51% <40.32%> (+0.02%) ⬆️
temurin 61.65% <40.32%> (+0.12%) ⬆️
unittests 61.65% <40.32%> (+0.12%) ⬆️
unittests1 46.94% <ø> (+0.16%) ⬆️
unittests2 27.61% <40.32%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@klsince klsince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

ControllerMeter.CONTROLLER_REALTIME_TABLE_SEGMENT_ASSIGNMENT_MISMATCH, 1L);
// Check ZK metadata for uploaded segments to look for a segment that's in the same partition
for (String uploadedSegment : uploadedSegments) {
if (getPartitionId(uploadedSegment) == partitionId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a comment that there is no need to cache here, as assignSegment() is just one-time shot, but rebalance() can be called in a loop for multiple times

/**
* Returns the partition id of the given segment, using cached partition id if exists.
*/
private int getPartitionIdUsingCache(String segmentName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave a TODO about the check on whether segment's partition id is updated when uploading segment to replace the existing one, so we could catch such rare case during table rebalance, because if that case ever happens, the cache is out of sync from the segment ZK metadata

@Jackie-Jiang Jackie-Jiang merged commit a37ced6 into apache:master Nov 28, 2023
19 checks passed
@Jackie-Jiang Jackie-Jiang deleted the fix_rebalance_upsert branch November 28, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants