Change segment state on HttpLoadQueuePeon from "moving from" to "dropping" atomically #18824
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.
Description
Based on discussions with @jtuglu1 in #18764 , there seem to be some race conditions in segment balancing between the duty run thread and the segment drop callback thread (triggered by segment balancing).
Race condition 1
Duty takes snapshot of peon when segment is in the middle of being transitioned from state
MOVING_FROMtoDROPPING.ServerHolderassumes that this segment actually has stateLOADED(when in fact it should beDROPPING)StrategicSegmentAssignerto assume that the segment is over-replicated (being loaded on both A and B) and then trigger a drop from either A (no-op since we were going to start a drop from A anyway) or B (segment becomes briefly unavailable).Race condition 2
Duty takes snapshot of peon after the
DROPoperation has succeeded but it is not yet reflected in the inventory (since the inventory was snapshotted earlier in the flow).StrategicSegmentAssignerto consider this segment as over-replicated.Changes
segmentsMarkedToDroptosegmentsToDropatomically@GuardedByto ensure that these fields remain thread-safeLoadQueuePeon.getSegmentsInQueue()so that we track completed requests inside the peon until the inventory has confirmed success of the same.This PR has: