[GH-ISSUE #6298] [Issue]: An admitted file-store flush can reject during shutdown #3513

Closed
opened 2026-10-21 06:03:51 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Sep 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6298

Originally assigned to: @SpicyMarinara on GitHub.

Problem

A flush that starts while another file-store flush is active can reject with StorageWriterLeaseError: File-native storage is closing or closed and cannot accept writes when shutdown begins before the active write finishes. Background flush callers do not expect this admitted operation to become a new write attempt, so it can surface as an unhandled rejection during shutdown.

Observed in the Advanced Memory CI regression after all assertions passed: https://github.com/Pasta-Devs/Marinara-Engine/actions/runs/35267503389/job/105359549043.

Reproduction

  1. Pause the first settings write with the existing storage write hook.
  2. Start a flush and queue a second dirty settings row.
  3. Start another flush while the first is active.
  4. Start close(), then release the first write.
  5. The waiting flush recursively calls flush() after writes have been closed and rejects instead of joining the shutdown drain.

Expected behavior

Flushes admitted before shutdown finish with the existing close operation; accepted rows reach disk. New flushes and writes started after close remain rejected, and genuine persistence errors remain observable.

Owner: @SpicyMarinara, handled in the existing draft sweep #6295 and its storage/lorebook ancestor #6289. Extend the existing shutdown regression; keep the fix in the shared flush path.

Originally created by @SpicyMarinara on GitHub (Sep 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6298 Originally assigned to: @SpicyMarinara on GitHub. ## Problem A flush that starts while another file-store flush is active can reject with `StorageWriterLeaseError: File-native storage is closing or closed and cannot accept writes` when shutdown begins before the active write finishes. Background flush callers do not expect this admitted operation to become a new write attempt, so it can surface as an unhandled rejection during shutdown. Observed in the Advanced Memory CI regression after all assertions passed: https://github.com/Pasta-Devs/Marinara-Engine/actions/runs/35267503389/job/105359549043. ## Reproduction 1. Pause the first settings write with the existing storage write hook. 2. Start a flush and queue a second dirty settings row. 3. Start another flush while the first is active. 4. Start `close()`, then release the first write. 5. The waiting flush recursively calls `flush()` after writes have been closed and rejects instead of joining the shutdown drain. ## Expected behavior Flushes admitted before shutdown finish with the existing close operation; accepted rows reach disk. New flushes and writes started after close remain rejected, and genuine persistence errors remain observable. Owner: @SpicyMarinara, handled in the existing draft sweep #6295 and its storage/lorebook ancestor #6289. Extend the existing shutdown regression; keep the fix in the shared flush path.
bsakaguchi 2026-10-21 06:03:51 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 17, 2026):

Merged into staging through #6289 and #6295. A flush admitted before close now joins the existing shutdown drain instead of recursively failing as a new write. The shutdown regression reproduced the failure before the shared shutdown fix and now verifies both pending rows reach disk; failed admitted writes remain visible even when the shutdown retry succeeds; writer-lock and Advanced Memory regressions also pass.

<!-- gh-comment-id:5721307063 --> @SpicyMarinara commented on GitHub (Sep 17, 2026): Merged into staging through #6289 and #6295. A flush admitted before close now joins the existing shutdown drain instead of recursively failing as a new write. The shutdown regression reproduced the failure before the shared shutdown fix and now verifies both pending rows reach disk; failed admitted writes remain visible even when the shutdown retry succeeds; writer-lock and Advanced Memory regressions also pass.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3513
No description provided.