Fix endless creation of best possible nodes #2970
Merged
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.
Issues
Controller endlessly creates BEST_POSSIBLE nodes due to handleDelayedRebalanceMinActiveReplica #2971
Description
Controller endlessly creates best possible nodes under certain circumstances due handle
handleDelayedRebalanceMinActiveReplicamodifying the same underlying ResourceAssignments that are used for the in memory bestPossibleAssignmentThis PR changes
AssignmentMetadataStore's methodspersistBaselineandpersistBestPossibleAssignmentto create a copy of the underlyingResourceAssignmentobjects before persisting them to the store's in-memory map. This allows the object passed to these methods to be safely modified afterwards without affecting the cached bestPossible.There are specific circumstances to trigger this behavior:
PartialRebalance will async calculate a new best possible and increment the
_bestPossibleVersionand schedule an onDemandPipeline run. In emergencyRebalance(...) of the next pipeline, the bestPossibleAssignment (object A) will be persisted as_bestPossibleVersion!=_lastPersistedBestPossibleVersion. The values of the new best possible are stored in our in-memory bestPossibleAssignment map (object B). While object A and B are different, their values map to the same objects. We then pass object A tohandleDelayedRebalanceMinActiveReplicawhich modifies the values of object A, also modifying the values of object B. This causes partialRebalance to believe it has calculated a different assignment, so it triggers a new pipeline run which will repeat the above behavior ad infinitum.Tests
TestEndlessBestPossibleNodes
This test will fail on master, but pass on this branch
Changes that Break Backward Compatibility (Optional)
N/A
Commits
Code Quality
(helix-style-intellij.xml if IntelliJ IDE is used)