mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5651] Transaction rollback erases rows lazily loaded by a concurrent read, leaving the unit marked loaded #3131
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#3131
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/5651
Originally assigned to: @kolacheee on GitHub.
What happens
A transaction rollback can erase rows that a concurrent read lazily loaded into memory mid-transaction — and the unit stays marked loaded, so those persisted rows are invisible for the rest of the session. Disk is intact; a restart recovers them.
The mechanism (all in
packages/server/src/db/file-backed-store.ts)matchingRowsand select queries callensureQueryScopeLoaded→ensureUnitsLoadeddirectly from the reader's own context.mergeLoadedRows) mirrors loaded rows into the transaction snapshot only when the loader itself runs inside the transaction's ALS context. A concurrent HTTP request's read has no such context.loadedUnitsand the read-once shard-encoding set still say the unit is loaded, so nothing ever reloads it.This is the exact #5631 lazy-unit symptom via ungated reads instead of writes. It predates #5631's fix (the #5606 mirror only ever covered in-context loads).
When it matters
Needs a rollback (rare: a mid-transaction throw, realistically
StorageWriterLeaseErrorduring shutdown) racing a first-touch read of a cold chat — e.g. a user opening an old chat while a message edit's transaction fails. Low probability, invisible when it happens (the chat just looks empty until restart).Suggested direction
The queue guarantees at most one active transaction, so the store can keep a reference to the active transaction context and have
mergeLoadedRowsmirror into it wheneveractiveTransactionCount > 0, regardless of the loader's own ALS context. (Alternative: gate out-of-context lazy loads on the same two counters the write gate now uses, at a read-latency cost.)Found by the #5631 verification pass (adversarial review of PR TBD), which confirmed the write-side fix does not cover this path.