[da-vinci] Invalidate stale demotions before going offline - #2973
Open
sofiaz11 wants to merge 2 commits into
Open
[da-vinci] Invalidate stale demotions before going offline#2973sofiaz11 wants to merge 2 commits into
sofiaz11 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents a stale queued LEADER_TO_STANDBY consumer action from applying after a replica has already begun transitioning STANDBY -> OFFLINE, by invalidating the leader-session token at the start of the OFFLINE transition so later-processed demotions are rejected by the existing session-id validation in ingestion-task consumer-action processing.
Changes:
- Increment
leaderSessionIdat the beginning ofonBecomeOfflineFromStandby(...)to invalidate any previously queued demotion actions. - Add a unit test asserting the demotion’s session checker becomes invalid once the OFFLINE transition begins.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| clients/da-vinci-client/src/main/java/com/linkedin/davinci/helix/LeaderFollowerPartitionStateModel.java | Invalidates the leader-session token when starting STANDBY -> OFFLINE to reject stale queued demotions. |
| clients/da-vinci-client/src/test/java/com/linkedin/davinci/helix/LeaderFollowerPartitionStateModelTest.java | Adds a regression test intended to cover delayed demotion invalidation during OFFLINE transition. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+161
to
+184
| @Test | ||
| public void testOfflineTransitionInvalidatesDelayedLeaderToStandbyAction() { | ||
| Message message = mock(Message.class); | ||
| NotificationContext context = mock(NotificationContext.class); | ||
| when(message.getResourceName()).thenReturn(resourceName); | ||
| LeaderSessionIdChecker[] demotionChecker = new LeaderSessionIdChecker[1]; | ||
| doAnswer(invocation -> { | ||
| demotionChecker[0] = invocation.getArgument(2); | ||
| return null; | ||
| }).when(storeIngestionService).demoteToStandby(eq(storeAndServerConfigs), eq(partition), any()); | ||
|
|
||
| leaderFollowerPartitionStateModel.onBecomeStandbyFromLeader(message, context); | ||
| assertNotNull(demotionChecker[0]); | ||
| assertTrue(demotionChecker[0].isSessionIdValid()); | ||
|
|
||
| leaderFollowerPartitionStateModel.onBecomeOfflineFromStandby(message, context); | ||
|
|
||
| assertFalse(demotionChecker[0].isSessionIdValid()); | ||
| verify(heartbeatMonitoringService, never()).updateLagMonitor( | ||
| eq(resourceName), | ||
| eq(partition), | ||
| eq(HeartbeatLagMonitorAction.SET_FOLLOWER_MONITOR), | ||
| anyString()); | ||
| } |
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
sofiaz11
force-pushed
the
qizhu-linkedin-fix-stale-sit-demotion
branch
from
August 13, 2026 18:10
5a9aca0 to
eef7531
Compare
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.
Problem Statement
Asynchronous replica cleanup can advance a replica to
OFFLINEwhile an earlierLEADER_TO_STANDBYaction remains queued. If that delayed demotion runs afterward, it can modify ingestion state and restore follower heartbeat monitoring for an offline replica.Solution
Invalidate the leader-session token when the
STANDBYtoOFFLINEtransition begins. The existing consumer-action validation then rejects any queued stale demotion before it modifies ingestion state or heartbeat monitoring.Code changes
No configuration or logging changes are introduced.
Concurrency-Specific Checks
Both reviewer and PR author to verify
synchronized,RWLock) are used where needed.ConcurrentHashMap,CopyOnWriteArrayList).The existing atomic leader-session generation provides the cross-thread validity check. This change introduces no collections, blocking calls, or exception-handling changes.
How was this PR tested?
The focused regression test verifies that the delayed demotion token becomes invalid and no later
SET_FOLLOWER_MONITORupdate occurs.Does this PR introduce any user-facing or breaking changes?
This contribution is original work and is licensed to the project under its open source license.
🤖 Generated with GitHub Copilot CLI