Skip to content

fix: prevent stream resurrection and staging races during deletion - #1858

Merged
nikhilsinhaparseable merged 9 commits into
parseablehq:mainfrom
AadishJ:fix/async-deletion-race-conditions
Nov 12, 2026
Merged

nikhilsinhaparseable merged 9 commits into
parseablehq:mainfrom
AadishJ:fix/async-deletion-race-conditions

Conversation

@AadishJ

@AadishJ AadishJ commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Serialize DELETE handling and local cleanup with stream creation/update, preventing delayed cleanup from affecting a recreated stream.
  • Recheck the durable tombstone before a background deletion job starts cleanup.
  • Coordinate staging cleanup with ingestion, schema writes, writer finalization, and local conversion to prevent deleted files from reappearing.
  • Clean stale staging and reset statistics before evicting deleting entries, so recreated streams do not inherit old data or counters.
  • Retain deletion state when staging cleanup fails, allowing background cleanup or reconciliation to retry.
  • Prevent ingestion and object-store sync from implicitly recreating missing stream entries.
  • Add deletion guards to hot-tier reads and tests for ingestion error responses (409 Conflict for deleting streams and 500 for staging failures).

This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

RetriggerView in GreptileConfidence 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.

  • Stream deletion waits for local cleanup before a name can be reused.
  • Ingestion and file conversion stop touching staging once deletion starts.
  • Missing and deleting streams no longer look like active streams to callers.

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
    end
Loading

Reviews (10) · Last reviewed commit: "fix: update error handling in queued pus..." · Reviewed by Greptile

@AadishJ
AadishJ marked this pull request as ready for review November 11, 2026 14:05
Comment thread src/parseable/streams.rs Resolved
Comment thread src/event/mod.rs Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026
…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.
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026
- 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
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 11, 2026
Signed-off-by: Aadish Jain <jain.aadishj@gmail.com>
Comment thread src/parseable/streams.rs Resolved
Comment thread src/parseable/streams.rs Resolved
Comment thread src/parseable/streams.rs Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 12, 2026
@nikhilsinhaparseable
nikhilsinhaparseable merged commit bdaba3d into parseablehq:main Nov 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants