fix snapshot race condition in heavy workloads by krunal1313 · Pull Request #2878 · typesense/typesense · GitHub
Skip to content

fix snapshot race condition in heavy workloads#2878

Open
krunal1313 wants to merge 5 commits into
typesense:v31from
krunal1313:fix_snapshot_race
Open

fix snapshot race condition in heavy workloads#2878
krunal1313 wants to merge 5 commits into
typesense:v31from
krunal1313:fix_snapshot_race

Conversation

@krunal1313

@krunal1313 krunal1313 commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Change Summary

Summary

This change hardens on-demand snapshot export behavior for issue #2872 using Typesense-side safeguards only.

Fixes

  • Snapshot requests are now guarded earlier, so overlapping snapshots are rejected before they start.
  • Timed snapshots and on-demand snapshots now use the same in-progress guard.
  • The snapshot request path handoff was cleaned up so the export path is carried through the closure instead of shared mutable state.
  • External exports now write to a temporary directory first.
  • External exports move into place only after the copy succeeds.
  • Failed exports should no longer partially overwrite a previous good snapshot.
  • The braft snapshot-reader patch was removed; external export still copies from the raft snapshot directory.

Result

  • Concurrent snapshot requests now return 409 Another snapshot is in progress instead of running in parallel.
  • Snapshot export is safer for the destination path under heavy write load.
  • Previous good external snapshots are protected from partial overwrite on export failure.

PR Checklist

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.

2 participants