mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5652] Check-once activeFlush await lets a second flush run concurrently with a transaction and persist uncommitted rows #3130
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#3130
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 @kolacheee on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5652
Originally assigned to: @kolacheee on GitHub.
What happens
A narrow pre-existing window lets a flush run concurrently with a transaction callback and persist uncommitted rows to disk with no dirty mark left behind. Verified byte-identical before and after the #5631 gate fix — the fix neither widened nor narrowed it; filing so it isn't lost.
The mechanism (
packages/server/src/db/file-backed-store.ts)transaction()'s openingif (this.activeFlush) await this.activeFlush;is check-once, not a loop. The crack needs a double-flush ordering:await this.activeFlush(flush 1) while a secondflush()call is also parked on the same promise, subscribed first.activeFlush.saveFileSnapshotsreadsthis.tableslive during writes, so a table in flush 2's captured dirty set that the transaction mutates early can be persisted with uncommitted rows. A rollback then restores memory and the PRE-transaction dirty flags, leaving the uncommitted rows on disk with no dirty mark until some later write happens to dirty that shard again.When it matters
Requires two overlapping flushes plus a transaction landing between them plus a rollback — rare, but the failure is persisted uncommitted data, the worst kind to leave unfixed silently.
Suggested fix
One line: make the opening check a loop —
while (this.activeFlush) await this.activeFlush;— so the transaction re-checks after every flush completion and can never activate concurrently with a fresh flush's capture. (Worth a small staged regression via the existingbeforeTableWritetest hook, which can hold flush 2 mid-write.)Found by the #5631 verification pass while auditing the gate fix's interaction with flush parking.