mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7804] [MERGED] fix(storage): reclaim a dead writer lease on Windows when the machine id probe times out #7932
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#7932
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/7804
Author: @SpicyMarinara
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/19/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/7801-windows-writer-lease📝 Commits (1)
5bcfa35fix(storage): reclaim a dead writer lease on Windows when the machine id probe times out📊 Changes
2 files changed (+138 additions, -28 deletions)
View changed files
📝
packages/server/src/db/file-backed-store.ts(+72 -28)📝
scripts/regressions/storage-writer-lock.regression.ts(+66 -0)📄 Description
Linked issue
Closes #7801
Why this change
reg.exelaunch in a Node process takes about 2 s. The MachineGuid probe had a 1 s budget and ran only once at module load, so the server sometimes started with no host id.data/storage/.writer-leaseby hand. The reporter measured this in detail; it is the evidence #6674 asked for.hostId: null).What changed
readStableMachineId()(win32 only): timeout raised from 1 s to 2 s, in line with the boot-id probe, with one retry when the probe hitsETIMEDOUT. The reporter measured the secondreg.execall in the same process at about 40 ms. macOS and Linux probes are unchanged.acquireWriterLease(): the existing #5744/#5799 "local-storage" same-host proof now also applies to the mirror case. This process has no host id, the lease records one, and the storage is machine-local. The existing PID checks then decide, with their PID-namespace requirement unchanged. A live PID keeps its lease, and shared or network storage stays locked. A known host id that differs from the lease's still never uses the storage proof.writerLeaseBootIdsMatch(): on win32, twoLastBootUpTimeboot ids up to 5 minutes apart count as the same boot. The reporter saw the same boot recorded about 6 s apart. Before this change, that jitter could make the boot check reclaim the lease of a writer that was still alive. Now a near match skips only the boot proof, and the PID checks decide. This makes reclaims stricter and never looser. The on-disk format is unchanged, andstorage-format.json/STORAGE_VERSIONare not bumped.writerLeaseHostIdtest hook (null simulates a failed probe), used by the regression.Limitation (follow-up):
writerLeaseStorageIsMachineLocal()returnsfalseon Windows, since only Linux/Android expose a filesystem magic. So on Windows the mirror proof is not reached, and the fix for the reported case is the probe retry. Two cases remain manual-recovery on Windows, as before this PR:hostId: nulllease was written by a process whose probe failed (the reporter's current lease is one). A later start with a working probe still cannot use the storage proof there.A Windows storage-locality proof is the follow-up. It would need a UNC/mapped-drive check, plus a PID-proof rule for Windows, which has no PID namespace.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent on macOS:
pnpm build:shared && node ./scripts/run-regressions.mjs --filter storage-writer-lock: passed. New cases:writerLeaseBootIdsMatchwith the reporter's two jittered boot ids on win32 gives the same boot; hours apart, on linux, or with non-timestamp ids it does not.storage-writer-lockfails, so the new case pins the fix.node ./scripts/run-regressions.mjs --filter <name>forbackup-folder-lease,robustness-boot-performance,automatic-backup-retention,lorebook-scan-compactionandlauncher/update: each passed.pnpm check: passed.Manual verification notes
reg.execall is slow that a fresh server start writes a non-nullhostIdindata/storage/.writer-lease/owner.json..writer-leaseby hand.StorageWriterLeaseError.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)No user-facing docs change: the existing troubleshooting text about removing
.writer-leasestill applies to the remaining manual cases.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.