mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5607] [MERGED] fix(storage): re-merge load-created healing marks on transaction rollback #6845
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#6845
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5607
Author: @kolacheee
Created: 8/28/2026
Status: ✅ Merged
Merged: 8/28/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5606-tx-load-heal-marks📝 Commits (1)
f734c49fix(storage): re-merge load-created healing marks on transaction rollback📊 Changes
3 files changed (+99 additions, -0 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/db/file-backed-store.ts(+49 -0)📝
scripts/regressions/lazy-chat-units.regression.ts(+49 -0)📄 Description
Why
Closes #5606 — the pre-existing data-loss corner found during #5603's adversarial verification (reproduced on the parent commit with eviction disabled, so it has been latent since #5597 merged). A chat shard file holding another chat's misfiled rows — the exact state the store's self-healing exists to repair — could lose those rows' only on-disk copy if the unit loaded inside a transaction that rolled back.
What
A lazy unit load creates its healing marks in one synchronous block: dirty keys for every row's real shard, plus a stale mark on the stray-holding file. The flush's write-then-unlink ordering is only safe because those travel together. Rollback broke the pairing: it restored
dirtyShards/dirtyTablesfrom the pre-transaction snapshot (erasing the load's keys) while the stale mark — correctly never rolled back — survived alone. The next flush rewrote the host file canonically without the stray, and the stray's own shard was skipped by the clean-shard fast path.Loads are deliberately not transaction mutations — their rows survive rollback via the existing snapshot mirror. Now their marks do too: the transaction context records load-created dirty keys/tables (all three creation sites: shard-file heal, empty-
.bakstale, duplicate drop), and rollback re-merges them. The invariant restored: a stale mark never reaches a flush without the dirty keys it was created with — the same pairing rule the flush-capture work in #5597/#5603 enforced for in-flight flushes, now enforced across rollbacks.Regressions
New block in
lazy-chat-units.regression.tsstaging the exact interleaving (misfiled row whose canonical shard file exists — the file-absent variant is masked by the recreate-if-missing rule; mid-transaction load; forced rollback; flush) asserting the misfiled row is re-homed rather than erased. Verified red against the pre-fix store on exactly that assertion. Full lazy suite plus message-sharding in both lazy and eager modes green locally.Test plan
pnpm checkon a non-Windows checkoutpnpm regressionSummary by CodeRabbit
Bug Fixes
Tests
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.