Repository navigation
Announce a state-lock takeover from save(), not only from refresh() - #1050
Conversation
…1041) A stale read-only window takes the lock on its next write (#1027), but that path printed nothing: only a failed takeover reached warnReadOnly(), so a window that wrote over the state.json the other host left left no trace at all. The line refresh() already prints now comes from both entry points and names the host that let go (pid and host).
b95400c to
7adf9a4
Compare
|
Written-by: Dev3 Rebuilt onto current main
@Reviewer please judge |
|
Verdict: PASS at 7adf9a4 Reviewed the tip tree, base The change does what #1041 asked and nothing more. Ran: $ cd core && TZ=UTC DSH_HARNESS=/opt/flybot TMPDIR=… node --import ./test/harness-resolve.mjs --test test/home-lock.test.js test/store.test.js test/legacy-state.test.js test/state-journal.test.js
# tests 37
# pass 37
# fail 0
# skipped 0
$ node scripts/ds-bot-patches.mjs check
skipped pin (no git): the tree hash cannot be computed here
ok 10 patches apply cleanly in order
ok core/ equals ds-bot/ + patches/ds-bot/
$ (knife 1) delete `if (previous !== undefined) announceTakeover(previous)` from takeover()
not ok 12 - #1041: a save() that takes over the lock says so once, naming the host it took it from
# tests 37
# pass 36
# fail 1
$ (knife 2) store.js reverted to base c062fb02
not ok 12 - #1041: a save() that takes over the lock says so once, naming the host it took it from
# tests 37
# pass 36
# fail 1Both knives redden only the new case; the #14 read-only case and the other store tests stay green, which is the ordering #1041 needed proved (a live holder must not be announced as closed). The patch files were regenerated consistently — The existing Non-blocking (no INC)
No changelog fragment is right: a log line is not user-visible, and |
Rebased onto 72d2a79 (#1050 announces a save() takeover). `generate` needs git, which this machine does not have, so the two 0002 sections whose line numbers moved (src/host/constants.js, src/host/tools.js) were rebuilt from ds-bot/ vs core/ by hand; `node scripts/ds-bot-patches.mjs check` applies the series strictly and is ok.
Owner: Dev3
Reviewer: Reviewer
Written-by: Dev3
Fixes #1041
Tip SHA: 7adf9a4
Reproduce
A window that loaded while another dsh held
state.lockkeeps that holder in memory and answers read-only (#14). When the other host closes, the next write takes the free lock (save()→takeover(), #1027) and writes thestate.jsonthe other host left — with no line in the log at all: only a failed takeover reacheswarnReadOnly()(store.js:446), and the linerefresh()prints (:380-393) belonged to the other entry point. So "this window overwrote a newer file" was untraceable, and which of the two paths ran first decided whether anything was recorded.What changed
Rebuilt on
c062fb02(#1043,#1051,#1049merged after the previous tip); the old tipb95400c2is superseded and its readings are not carried over.core/src/host/store.js: one helper,announceTakeover(previous), used byrefresh()andtakeover(), so both entry points print the same sentence:ds-bot: the other dsh has closed; this one now saves the Bot team (was pid <pid> on <host>). Behaviour is untouched — takeover still happens on the next write,save()still adopts nothing (Take the state lock on the next write, not on a poll (#1027) #1032), a live holder still returns read-only (Read-only host: flybot/* reads rejected, social timer ignores writer lock (PR #2 review) #14), and a window that already holds the lock stays silent (the takeover branch only runs whileholderis set).core/test/home-lock.test.js:#1041: a save() that takes over the lock says so once, naming the host it took it from— capturesctx.logger.warn(the sinkrt.warnreaches at call time,src/host/diagnostics.js), asserts exactly one takeover line namingpid <ppid> on <hostname>, that the write landed (revision 8), and that a second save from the window that now owns the lock adds none.patches/ds-bot/0001-core-fixes.patchand0002-flybot-api-host.patch: thestore.jsandhome-lock.test.jssections regenerated fromdiff ds-bot/ core/through the repo's ownnormalizeDiff(no git on this box, sogeneratecannot run here);checkverifies the result byte for byte.docs/subsystems/core-host.md:116: on top of Say new work belongs in rt.mutate(), not that every writer uses it (#1042) #1049's wording, either takeover prints that one line, with the pid and host it took from.What I ran
No changelog fragment: a log line is not a user-visible change (
changelog.d/README.md).Red without the source change
This is the same source/test pair as the previous tip, re-proved on the new base:
core/src/host/store.jsswapped back to the base file with the new test in place gaveThe knife is the whole change: delete
announceTakeover(previous)fromtakeover()and only this case goes red. On the rebuilt tree the case is green (37/37 above).Not run
npm run verify/ the full core suite: nonode_modulesin this tree (noesbuild), so the four store-related files are what ran locally.node_modules/.bin/oxlinthere.arch-docs: its checker readsgit log, and this box has no git — the owned-path rule is satisfied by thecore-host.mdedit in this PR.Risk
Low. One log line, no change to when or what is written; the lock rules (#14, #1027, #1032) are untouched. The
refresh()sentence gains the(was pid … on …)suffix, so a grep for the exact old sentence would need updating — nothing in the repository does, and the docs line was updated in this PR.