Repository navigation
fix(cluster): an object authored during a store outage is served by every replica after its resync - #31816
Conversation
…try on cluster.resync An object authored while the cluster store was unreachable lost its metadata.mutated hint, so every other replica answered it as unknown until restart. The protocol now offers resyncMetadataMutationPubSub(): one read of sys_metadata's active rows (address and checksum) names each item a lost hint could have touched, and each is re-converged by the delivered-hint applier from the replica's own re-read. A failed read is never a delete. The bridge registers the seam with the other lanes; the memory driver never emits the event. Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE Co-authored-by: Claude <noreply@anthropic.com>
…e metadata.mutated lane Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE Co-authored-by: Claude <noreply@anthropic.com>
…latform On a booted stack with security, the baseline and active-row reads carried no principal and were refused, so every resync failed. Both reads now carry the system context, as the repository's own reads do. The fan-out harness refuses a principal-less column-subset read, as the secured engine does. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
…package's lib target Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
…t inside a case Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
📓 Docs Drift CheckThis PR changes 2 package(s): 20 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 9 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 13 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 711cfd6589f5d368bfcc070b3185de302d7207dd && git checkout 711cfd6589f5d368bfcc070b3185de302d7207dd
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 6be71abc34cdd7adcc6057d121479ba5a11724e3 70a463152e646ffc8383c5df9e644abe1d79fb94 && git checkout -B drift-repro 6be71abc34cdd7adcc6057d121479ba5a11724e3 && git merge --no-ff 70a463152e646ffc8383c5df9e644abe1d79fb94
node scripts/docs-audit/affected-docs.mjs --json 6be71abc34cdd7adcc6057d121479ba5a11724e3
|
|
domain:server#1 · os-steve · session_01ADHkmPF1skfu2kx89BEXZi 席位 ACCEPT · head
|
Requested by Steve · project thread
Fixes #31722
Clause-②: yes (widening)
Metadata-protocol: none
Measured on the diff: one new public method,
ObjectStackProtocolImplementation.resyncMetadataMutationPubSub(), and itsresult type
MetadataMutationResyncReport, exported from@objectstack/metadata-protocol. Nothing is removed or made required. Theclaim read
no; the measurement saysyes (widening), as it did for #31721.No metadata an author writes changes.
维护者速读
cluster.resync)后会自动收敛,不再需要重启。metadata.mutated通道(让其他副本注册新对象的那条)是唯一没有重同步入口的通道;断线期间丢失的提示会让其他副本一直回答OBJECT_NOT_FOUND(或旧定义、或已删除的对象),直到重启。sys_metadata,读失败时不删除任何注册项。回滚即撤销本 PR。metadata-protocol的新文件protocol-mutation-resync.ts(选哪些项重新收敛),以及service-cluster的metadata-cluster-bridge-plugin.ts(注册一行)。cd packages/runtime && pnpm exec vitest run src/cluster-metadata-mutation-resync.integration.test.ts,两个内核共享一个 SQLite 文件和一条会丢消息的总线。What changes
Lane 2 has a resync seam (
@objectstack/metadata-protocol).resyncMetadataMutationPubSub()readssys_metadata's active rows once,with only their address and
checksumand never a body. It thenre-converges each item a lost hint could have touched:
save or publish);
delete);
brings an earlier checksum back, so the checksum alone cannot tell).
Each item goes through
applyRemoteMetadataMutation, the applier adelivered hint runs, from this replica's own re-read. Nothing travels on the
wire. A row that is gone takes the delivered delete's heal walk.
The baseline.
attachMetadataMutationPubSubseeds a per-replica ledgerwith one active-row read. Every convergence keeps the ledger current. Hints
and local writes mark items. Resyncs run one at a time, and an item touched
during a resync stays marked. With no baseline (the seed read failed), the
first resync re-converges every active row.
A read that fails is never a delete.
stays marked for the next resync. The failures are logged once per resync
(
console.error, with the items and the first cause).The bridge calls it (
@objectstack/service-cluster).MetadataClusterBridgePluginregisters lane 2 throughregisterLaneResyncon the same
cluster.resyncevent as lanes 1, 3, 4 (fix(cluster): a Redis outage must not crash replicas; resync caches on reconnect #31721) and 5 (feat(cluster): settings changes reach every replica (settings lane) (#3814 F3b) #31597). A protocolthat predates the seam is skipped, and a rejected resync is a warning, as
for the other lanes.
Docs.
content/docs/kernel/cluster.mdx§6.2 and the bridge docblock nowdescribe lane 2's resync instead of "Lane 2 has no resync yet".
Why
#31721 left the
metadata.mutatedlane as the one lane without a resync. Itshint is what makes a peer re-run the ObjectQL registry write-through. So a hint
lost during a store outage left every other replica answering
OBJECT_NOT_FOUNDfor an object authored meanwhile (or serving its old body,or serving it after a delete) until restart.
Step 0: full re-convergence vs a diff
Measured on a booted showcase (
bootShowcase,OS_METADATA_WRITABLE=object),with N objects authored and the lane attached:
The address-and-checksum read takes ~1 ms at both sizes. These are
shared-box timings, so read them as ratios.
Choice: the diff. A full re-apply costs one delivered-hint convergence per
stored row on every reconnect. Each convergence also replays the item into
the local mutation listeners, and some of those re-sync a whole family per
event (authored hooks and actions). So the cost grows with the catalog even
when nothing was lost. A since-timestamp re-read was ruled out:
A finding from the measurement
On the booted showcase, the first build's resync and seed reads were refused
with
PermissionDeniedError(a read under a context that carries noprincipal). Every resync would have failed on a secured stack. Both reads now
carry
context: { isSystem: true }, as the repository's own reads do. Thefan-out harness now refuses a principal-less column-subset read, as the
secured engine does, so this is pinned (A8a/A8b below). The two-kernel test
has no security plugin, so it could not catch it.
Tests
packages/metadata-protocol/src/protocol.cluster-mutation-fanout.test.ts:a new
[#31722] cluster.resyncdescribe with 10 cases. The shared harnessgains a read fault (every read, or item re-reads only), the registered
labels, and the principal-less refusal:
re-applied;
packages/services/service-cluster/src/metadata-cluster-bridge-plugin.test.ts:resync is a warning.
packages/runtime/src/cluster-metadata-mutation-resync.integration.test.ts(new): two
LiteKernels over one SQLite file, a lossy bus, atest-busdriver with liveness, and the real bridge.
cluster.resyncruns. B serves the object and its row.memorydriver, the seam is never called (R3: thein-process driver never emits
cluster.resync).Ablations
Each was run against the tests above, first on the pre-merge head and again
on the merged head. All went red both times, and each restore left the file
equal to HEAD.
distThe A1 runtime leg uses a preflight marker that is present in the pristine
dist, absent under the mutation, and present after the restore.Acceptance notes
applier. A per-item re-read failure is logged and kept, not deleted.
that crosses a process boundary).
memorydriver never emitscluster.resync, and the bridgenever attaches lane 2 on it.
file and §6.2 and landed first.
mainis merged in after it (a mergecommit). Lane 5 stays at
kernel:bootstrappedwithsubscribeResync()inboth phases; lane 2 registers at
kernel:readylike lanes 1 to 4.Verification
Per touched package,
pnpm typecheckand package-scoped lint (root eslinton the directory,
--no-inline-config) exit 0. A fullvitest run:All of the above ran on the merged head
70a46315.dispatch-gates.mjs --commandswas derived on70a46315and gave 104commands. Each was run (all exit 0) and reconciled with
--ran: 104derived, 104 run, 0 NOT-MEASURED.
check-nul-bytesexits 0.Forced test edits: none. The existing bridge resync cases gained lane 2 in
their assertions, and the fan-out suite's shared harness was extended.
Human Minimum
packages/specholds no runtime logic. (packages/specuntouched.)pnpm lintpasses.main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE