mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3602] [Issue]: Graceful shutdown can drop writes queued during an active file-store flush #1948
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1948
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Xelvanis on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3602
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Severity: Medium — rare data-loss race. Graceful shutdown can finish while an asynchronous file-store flush is still running and a newer dirty write is waiting behind it. The process then exits successfully, but the latest mutation may not have reached disk.
Expected behavior
FileBackedStore.close()should wait for any active flush to finish, then flush changes that accumulated during that write before reporting that shutdown is complete.Actual behavior
When
flush()is called whilethis.savingis true, it marks the store dirty and returns immediately.close()clears the timers and callsawait this.flush(true), but that await also returns immediately if a flush is already active. The active flush does not schedule or drain a follow-up pass when it finishes, and the normal SIGINT/SIGTERM path then exits the process.This leaves a narrow sequence where a mutation made after the active flush captured its snapshot is absent from the file even though graceful shutdown completed without an error.
Steps to reproduce
atomicWriteFileso a flush remains active after the target table has been serialized.app.close()path.Environment
bcd4e836)Logs, screenshots, or video
No server error is emitted because
close()resolves successfully.Deterministic ephemeral reproduction output:
The second insert occurred during the active flush before
close(), but was still absent from disk after the original flush was allowed to finish. A negative control with the same two inserts followed by an ordinary close, with no active flush, persisted both rows.Additional context
app.close()so the file-backed store would be flushed before exit.58ffdfd7and adjusted in55aac5cb.close()await it, then drain any dirty tables accumulated during that flush. Persistent I/O errors should still propagate rather than causing an endless retry loop. No file-format or public API change should be required.Template check
Please uncheck (untick) the checkbox below before submitting this issue.
@SpicyMarinara commented on GitHub (Jul 14, 2026):
Claimed by @SpicyMarinara. I’m implementing a tracked active-flush promise and close-time dirty drain, with deterministic regression coverage for a write queued during an in-flight flush. I’ll preserve I/O error propagation and avoid retry loops.
@SpicyMarinara commented on GitHub (Jul 14, 2026):
Fixed in #3605 and merged to
stagingasacc3d3b22. Graceful close now awaits the active flush, drains writes queued after snapshot capture, and reports persistent close-time I/O failures. Deterministic regression coverage, full checks, UI smoke, container build, and CodeRabbit review passed.