mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5631] Transaction rollback can silently revert a plain write that raced the transaction's opening gate #3117
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#3117
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/5631
Originally assigned to: @kolacheee on GitHub.
What happens
The file store's transaction rollback can silently revert a concurrent non-transactional write that slipped through a check-then-act window. Found during adversarial review of the #5599/#5600 fixes; it predates them (the store has worked this way since transactions landed), but message edits now run in a transaction, so the window has more traffic near it.
The mechanism (all in
packages/server/src/db/file-backed-store.ts)await this.waitForWritableTurn()and applies its mutation in a following microtask.transaction()incrementsactiveTransactionCountonly afterawait previousTransactionandawait this.activeFlush.ctx.snapshots.set(tableName, currentRows.slice())).When it matters
Rollbacks are rare (a mid-transaction throw), and the interleaving window is a microtask — so this is a low-probability silent-revert, not a live data-loss report. But the failure is invisible when it does happen: e.g. a
createMessagefrom an in-flight generation lands in the window while a message edit's transaction throws (StorageWriterLeaseErrorduring shutdown is the realistic thrower), and the new message disappears from memory.Suggested direction
Close the gate atomically: reserve the transaction slot (increment
activeTransactionCount, or set a "transaction pending" flag thatwaitForWritableTurnhonors) before the awaits intransaction(), so no plain write can pass the gate between slot acquisition and the snapshot. Alternatively, snapshot-on-first-mutation could verify no table generation bump occurred since the transaction began and fall back to a conservative abort.Found by the #5599/#5600 verification pass; the reviewers verified the message-edit transaction itself is otherwise sound (rollback restores all three tables and re-pairs load-heal marks per #5606).