Repository navigation
Prevent late DELETE requests from resurrecting deleted jobs - #910
Open
LoopedBard3 wants to merge 1 commit into
Open
LoopedBard3 wants to merge 1 commit into
LoopedBard3 wants to merge 1 commit into
Conversation
Synchronize DELETE with terminal-state publication using the same per-job monitor. Keep logging outside the worker critical section and cover both transition orderings and existing HTTP behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 083b3d15-ae89-4560-9534-38e65695d3be
There was a problem hiding this comment.
🟢 Approval recommended
The shared monitor correctly serializes the two transitions, existing responses are preserved, and no unresolved issues were identified.
No open issues 🎉
What changed in this PR
Prevents late or repeated DELETE requests from moving completed jobs back from Deleted to Deleting, while preserving existing HTTP responses.
Changes:
- Guards DELETE state changes with the same per-job monitor used for worker completion.
- Extracts terminal-state publication into an internal helper, keeping cleanup and logging outside the lock.
- Adds regression tests for repeated requests, missing jobs, non-deleted states, and both concurrent transition orderings.
| File | Description |
|---|---|
| test/Microsoft.Crank.UnitTests/JobDeletionTests.cs | Tests deletion behavior and synchronized terminal-state preservation. |
| src/Microsoft.Crank.Agent/Startup.cs | Publishes Deleted under the job monitor and logs afterward. |
| src/Microsoft.Crank.Agent/Controllers/JobsController.cs | Preserves Deleted under the shared monitor without changing responses. |
Review effort: Balanced
LoopedBard3
marked this pull request as ready for review
October 21, 2026 22:40
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.
Summary
A late or repeated DELETE can change retained job metadata from
Deletedback toDeletingafter its run group has finished. The worker selects new groups throughNewjobs, so the old run need not be processed again even though cleanup has already completed.202/Locationand missing-ID204responses.Verification
Reproduced the defect against freshly fetched upstream main at
0d35cad5102892b091d9a88a52ea1f7a91bb1381. The original terminal-preservation assertions failed with expectedDeleted, actualDeleting.Final result on Windows/.NET 10: 39 passed, including 16 new cases and 23 existing controller tests. The race tests also reject a guard moved outside the controller lock and an unlocked worker publication; the correct implementation was restored and revalidated afterward.
This verifies the current-upstream defect and local fix, not the source revision of any previously deployed binary. No benchmark, deployment, Linux, or live-agent validation is claimed. Other state-writer races and controller behavior are outside this change.