Repository navigation
fix(cluster): a Redis outage must not crash replicas; resync caches on reconnect - #31721
Conversation
…ne resync seams Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
…t on LiteKernel Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
… instance held The single-node control now reproduces the lost-correction shape with no transport on either replica, so it goes red if the resync reconciles without one. Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
…ptional A door attached through setConnectorCredentialDoor() without the new member still type-checks, and a resync on it does nothing. The changeset now declares the measured widening. Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
…oad drivers at collection The real-redis outage test now resolves @objectstack/core and @objectstack/service-job through anchored source aliases, and the datasource convergence test pays its drivers' first load at module top. Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
…nding it in a test A module-top import of the memory driver satisfied the source-reach rule but is a new arrival in the memory-driver census. The package's vitest config now aliases it to source, which retires the shrink-only registry entry that let it resolve through dist. Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 6 package(s): 16 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 5 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 25 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 8cafa34b6c583efdb7370284df595fe01f81d9ea && git checkout 8cafa34b6c583efdb7370284df595fe01f81d9ea
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 90cea476dedee4bb2586f60b4f469bba67904cf3 f2661d7099a0458cb377090860c18a573d4c4dd1 && git checkout -B drift-repro 90cea476dedee4bb2586f60b4f469bba67904cf3 && git merge --no-ff f2661d7099a0458cb377090860c18a573d4c4dd1
node scripts/docs-audit/affected-docs.mjs --json 90cea476dedee4bb2586f60b4f469bba67904cf3
|
…the redis outage settings Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
|
domain:server#1 · os-steve · session_01ADHkmPF1skfu2kx89BEXZi 席位 ACCEPT · head
|
…robe main added probeClusterDriverHealth() and its ClusterDriverHealth type. The passive reading this branch exports is now ClusterDriverLivenessHealth, and the docs say which reading is which. Claude-Session: https://claude.ai/code/session_01ADHkmT4XhMdYmBfwHE4sQ7 Co-authored-by: Claude <noreply@anthropic.com>
|
domain:server#1 · os-steve · session_01ADHkmPF1skfu2kx89BEXZi 席位 ACCEPT · 冲突轮 · head
|
Requested by Steve · project thread
Fixes #31596
Clause-②: yes (widening)
Metadata-protocol: none
Measured on the built declarations (
dist/index.d.tsof each touched package): new exports in@objectstack/service-cluster(CLUSTER_RESYNC_EVENT,ClusterDriverLiveness,offerClusterDriverLiveness,onClusterResync,readClusterDriverHealth,describeConnectionError,redactCredentialsand five types) and@objectstack/service-cluster-redis(REDIS_COMMAND_TIMEOUT_MS,watchRedisConnection,describeRedisTarget), optional membersRedisDriverOptions.logger,RedisPubSubOptions.liveness,DatasourceAdminServiceConfig.listConvergeNamesand the connector-credential door'sresyncFromCluster, and public methodsMetadataManager.resyncClusterPubSub(),DatasourceAdminService.resyncDatasourceMutationPubSub(),AutomationEngine.resyncConnectorCredentialPubSub(). Nothing is removed or made required. The claim readno; the measurement saysyes (widening). No metadata an author writes changes.维护者速读
service-job的cron-job-adapter.ts(不再崩溃)和service-cluster的新文件cluster-resync.ts(cluster.resync事件)。service-cluster-redis的redis-outage.real-redis.test.ts,它会在两个运行中的内核下停掉再启动 Redis。!是否保留由席位复核(见 Acceptance notes)。What changes
@objectstack/service-job).CronJobAdapterleader-elects every scheduled fire on the cluster lock. A rejectedacquireused to escape the timer callback as an unhandled rejection and end the process. It now skips that fire, and the next tick retries. A failedreleaseis absorbed, and the lease expires on its TTL. The adapter logs one warning per lock outage and one info line when the lock answers again. No process-wideunhandledRejectionhandler is added.runScheduledis the only lock caller in the job adapters.@objectstack/service-cluster-redis). The command connection and the pub/sub subscriber both get anerror/close/readylistener (watchRedisConnection). ioredis no longer printsUnhandled error eventper reconnect attempt. The driver logs one warning per outage, naminghost:portand never the URL or a password, and one info line when the connection returns. New optiondriverOptions.logger.createRedisClient()setscommandTimeout: REDIS_COMMAND_TIMEOUT_MS(2000 ms). ioredis arms it before offline queueing, so it bounds queued commands too.client.duplicate()inherits it, so the shared cache's derived connection is bounded as well.cluster.resync(@objectstack/service-cluster).ClusterDriverLivenessis the connection state machine a remote driver feeds. Read health withreadClusterDriverHealth(cluster), which returns{ driver, nodeId, state: 'unknown' | 'up' | 'down', since, outages, lastError? }, orundefinedon the memory driver. This is the accessor feat(runtime): /ready reports cluster driver health when multi-replica is declared (#3814) #31601 reads. When every failed connection is ready again, the liveness emits ONE local event,cluster.resync(CLUSTER_RESYNC_EVENT). Subscribe withonClusterResync(cluster, handler), which returns a disposer. The event is never published to peers. On the memory driver the subscription is an inert no-op. feat(cluster): settings changes reach every replica (settings lane) (#3814 F3b) #31597 joins here. The liveness is offered on the cluster instance under aSymbol.forkey, asdriver-connection.tsalready does.MetadataClusterBridgePluginsubscribes once and calls each attached lane's resync seam, with per-lane failure isolation:MetadataManager.resyncClusterPubSub()drops every list cache and the endpoint index; registry entries are kept.DatasourceAdminService.resyncDatasourceMutationPubSub()re-converges every datasource in the shared rows plus every pool this replica holds.AutomationEngine.resyncConnectorCredentialPubSub()runs the reconcile a peer's signal runs.AuthzClusterBridgePluginadvances the engine's write epoch with reasonremote, which retires cached grants exactly as a delivered remote hint does.R3: the single-node default path is unchanged (the memory driver offers no liveness, so no listener, latch or resync runs on it). Nothing switches on by itself: every new path needs the redis driver connected, and the bridges still attach only when
isInProcessClusterDriveris false. The split-brain guard is untouched, and the deploy README's "multi-node unsupported" line is untouched.Tests
service-cluster-redis/src/redis-outage.real-redis.test.ts(new) uses a realredis-serverwith a password. It is skipped where the binary is absent. TwoLiteKernelreplicas, each with the redis cluster driver and a cron job on a 100 ms interval, share one Redis. The Redis process is SIGKILLed and restarted on the same port. Pinned:cluster.resync;The second case dials a black-holed TCP server: a GET on the cache's
duplicate()d connection rejects withtimed outin about 2 s, not about 30 s.service-cluster/src/cluster-resync.test.ts(new) covers:close()and redaction;Each lane got a new describe:
metadata-cluster-bridge-plugin.test.ts: each lane is called once per outage, a failing lane is isolated, nothing runs after shutdown, and CONTROL memory.authz-cluster-bridge-plugin.test.ts: onebump('remote')while bridged, nothing after shutdown, and CONTROL TTL 0.metadata-manager-cluster.test.ts,datasource-cluster-convergence.test.ts,connector-credential-cluster.test.ts: a lossy bus loses a peer write, and the resync converges it (CREATE and DELETE for datasources, plus a no-churn case). Each has a CONTROL with no transport.cron-job-adapter.leader.test.ts: a rejected acquire across 10 ticks gives one warning and no rejection, recovery logs once, a release rejection is absorbed, and a timer-driven fire raises no unhandled rejection.Forced test edits: none. The authz bridge harness now hands back a stable
objectqlservice carrying awriteEpochseam; no existing assertion changed.Test resolution (from
pnpm check:test-source-alias):service-cluster-redis/vitest.config.tsaliases@objectstack/coreand@objectstack/service-jobto source. It previously re-exported the shared preset, and it keeps the preset's one setting.@objectstack/driver-sqlat module top.service-datasource/vitest.config.tsaliases@objectstack/driver-memoryto source. A module-top import of it would have been a new arrival inpnpm check:driver-memory-census(driver-memory census inundeclared-field-write-driver-split.integration.test.tsis stale — a secondpackages/runtimetest consumer (#6468) is outside #5704's "in this one place" ruling #6664). The alias retires that package's shrink-only@objectstack/driver-memoryentry inscripts/check-test-source-alias.mjs, as that gate requires. That is a one-token edit outside the card's file surface.Ablations (each through
scripts/ablation-replace.mjs; every one landed and went red, and every restore leftgit diff HEADempty):commandTimeoutremovedB5 first stayed green against a weaker control. That control was strengthened in its own commit, and B5 then went red.
Acceptance notes
The
metadata.mutatedregistry lane (lane 2) has no resync seam yet. It still converges per item on delivered signals and fully at boot. I recommend a follow-up card.Against a black-holed store the health reads
unknownorupuntil the socket errors. The command bound, not the health, is what stops a caller hanging.A
SET NXthat timed out client-side may still land on the server, so a lock can stay held until its TTL. The fire is skipped, never run twice.Out of the file surface:
service-cache/src/cache-service-plugin.ts,base.duplicate()) has noerrorlistener of its own, so it still prints ioredis'Unhandled error eventduring an outage.check:test-source-alias's source-reach remedy for a lazily loaded@objectstack/driver-memory(a module-top import) is a binding thatcheck:driver-memory-censusrefuses. Any edited test that reaches the default driver factory meets that conflict. This PR resolves it by aliasing to source.These are left for a follow-up.
The
!in the title: on a single node nothing changes. On the redis driver the only new default is the 2 s command bound. The changeset ispatchwith no BREAKING banner. The seat re-states whether the!stands.Verification
Per touched package, a full
vitest run,pnpm typecheckand package-scoped lint (root eslint on the directory,--no-inline-config) all exit 0:The datasource suite was re-run on the final head. Lint on
scripts/check-test-source-alias.mjsexits 0.Full dogfood (
pnpm --filter @objectstack/dogfood test, on2cb8ab79): 440 test files passed and 3 skipped; 3652 tests passed and 41 skipped. The only commit after it touches test resolution and a gate registry, not package source.dispatch-gates.mjs --commandswas derived on the final headbf098837and gave 105 commands. Each was run (all exit 0) and reconciled with--ran: 105 derived, 105 run, 0 NOT-MEASURED.Generated by Claude Code