Fix duplicate executions of the same action that caused scheduler state to get out of sync [1.6-patch-6] - #2648
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
MarcusSorealheis
approved these changes
Aug 3, 2026
MarcusSorealheis
left a comment
Member
There was a problem hiding this comment.
@palfrey could you take a look as well?
amankrx
self-requested a review
August 4, 2026 01:18
amankrx
approved these changes
Aug 4, 2026
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.
Description
The scheduler keeps a map from action key to the operation running that action. That map is how it notices two identical actions and makes them share one run.
When a client disconnected, the cleanup code deleted that action's map entry every time. It never checked whether the entry still pointed at the operation being cleaned up. So if an operation had already finished but its client entry was still hanging around, cleaning it up deleted the entry belonging to a newer operation for the same action digest. This caused "...are out of sync" / "should have had the unique_key" errors, hung CI builds with concurrent identical actions.
The cause is a race that orphans an action-key deduplication entry. The race starts when all clients of an operation disconnect while a worker still executes that operation. For example, after
client_action_timeout_swith no client keepalive, the state manager marks the in-flight operationCompleted(DeadlineExceeded)while the worker still executes it.In
memory_awaited_action_db, the cleanup of a completed operation removed itsaction_info_hash_key_to_awaited_actionentry in all cases. A late client drop can occur after a newer operation claims the same action key. In this case, the cleanup deleted the entry of the newer operation. Later requests for that action key did not deduplicate onto the live operation. Instead, the scheduler started a third operation for the same action. Each completion that occurs after a replacement claims the key repeats the fault. Now the cleanup removes the entry only when the entry still points at the operation that it cleans up.This change adds
late_client_drop_does_not_orphan_replacement_operationas a regression test.Type of change
How Has This Been Tested?
This change adds one regression test in
nativelink-scheduler/tests/simple_scheduler_test.rs:late_client_drop_does_not_orphan_replacement_operation— this test creates a race between a late client-drop cleanup and a replacement operation for the same action key. The test makes sure that the deduplication entry of the replacement operation survives.Checklist
bazel test //...passes locallygit amendsee some docsThis change is