Repository navigation
fix: prevent stream resurrection and staging races during deletion - #1858
Merged
nikhilsinhaparseable merged 9 commits intoNov 12, 2026
Merged
nikhilsinhaparseable merged 9 commits into
nikhilsinhaparseable merged 9 commits into
Conversation
AadishJ
marked this pull request as ready for review
November 11, 2026 14:05
AadishJ
force-pushed
the
fix/async-deletion-race-conditions
branch
from
November 11, 2026 15:08
c6922ce to
f264ec4
Compare
…streams Keep creation locks held until blocking cleanup finishes despite caller cancellation. Return 404 for wrapped missing-stream ingestion errors. Add regression tests for both fixes.
- Extract deletion execution for isolated production-path tests - Cover stale jobs, cleanup failures, retries, and statistics reset - Release deletion claims on cancellation before the first poll
Signed-off-by: Aadish Jain <jain.aadishj@gmail.com>
parmesant
approved these changes
Nov 12, 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.
Addresses #1855.
Description
Follow-up to the asynchronous stream deletion introduced in #1770. This PR addresses remaining races between deletion, ingestion, local staging cleanup, and stream recreation.
Coordinates deletion and recreation through shared locks, drains participating ingestion and staging work before cleanup, and keeps old stream handles marked as deleting rather than reactivating them.
409 Conflictfor deleting streams and500for staging failures).This PR has:


Confidence Score: 5/5
The PR appears safe to merge; the queued deletion-status issue is fixed.Summary
This PR coordinates stream deletion with ingestion, staging cleanup, and recreation.
The previous numbered finding is fixed. No new actionable issues were found in the changes since the previous review. Tests were inspected but not run.
Diagram
sequenceDiagram participant Request as Ingestion request participant Queue as Write queue participant Stream as Stream writer Request->>Queue: Queue event Queue->>Stream: Take writer lock and check deletion alt Stream is deleting Stream-->>Request: StreamDeleting → HTTP 409 else Write fails Stream-->>Request: QueuedWrite → HTTP 500 else Write succeeds Stream-->>Request: Success endReviews (10) · Last reviewed commit: "fix: update error handling in queued pus..." · Reviewed by Greptile