mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5600] Message edit writes the messages row and its swipe mirror non-atomically — a badly timed crash leaves pre-edit text in exports and branches #3102
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#3102
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 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5600
Originally assigned to: @kolacheee on GitHub.
What happens
Editing a message writes the new text twice — once to the
messagesrow and once to the activemessage_swipesrow (the mirror that makes edits survive swipe switching). These two writes are not atomic: inupdateMessageContent(packages/server/src/services/storage/chats.storage.ts:1761-1810) the messages-row update (:1782) and the swipe-row update (:1805) are separated by several awaited calls (memory-chunk invalidation, a re-read, a swipe list read), and nothing wraps the sequence indb.transaction.If the server dies in that window — or a debounced flush happens to run between the two writes and the process dies before the next flush — the edit persists on the
messagesrow while the active swipe row still holds the pre-edit text.What a user actually sees
The chat itself looks fine after restart (the UI renders the messages row, and switching swipes away copies the current message content back onto the outgoing swipe, which heals the pair). The stale text survives in the paths that read swipe rows directly:
So the symptom is "my export/branch has an old version of a message I know I edited" — confusing precisely because the live chat shows the edit.
There's also a transient, milliseconds-scale version with no crash needed: a concurrent read between the two writes sees the message row and its active swipe disagree. Mostly invisible today since the UI renders message content, but any consumer comparing the two can observe it.
Suggested direction
Wrap the messages-row update and the swipe-mirror update in one
db.transaction(the store already supports it, defers flushes while a transaction is active, and rolls both back together on failure). That closes the crash/flush-timing tear; the transient read window shrinks to nothing user-visible.How verified
Code reading on current
staging(line numbers above) as part of the #5592 Phase 2 concurrency review: nodb.transactioninupdateMessageContent, awaited gaps between:1782and:1805, andsetActiveSwipe's copy-back at:2116-2122is what hides the tear in the live UI. Not a #5592 regression; the two-write mirror predates the sharded store.