Review of #134 r2 (one P2): duplicate volume/replica keys in one report
were accepted. The health transition compared against the first prior
match while every entry was stored, so repeating [healthy, unhealthy]
for one key invented a replica_unhealthy event that did not describe
the stored slot.
The observation store now refuses an observation with a repeated slot
key (ErrInvalidObservation) before any mutation, so no transition and
no store change result; validateHeartbeat refuses it at the RPC with
the offending indices. Distinct slots are unchanged.
TestStatusFrontendsForAssignedVolume_DedupesRepeatedFacts ingested its
fact through a heartbeat that repeated the slot; what it pins is the
status dedupe over repeated replica IDs, so it now ingests the fact
once. No production heartbeat repeats a slot (one slot per blockvolume
process).
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #134 r2: store controls (conflicting and identical duplicate
volume/replica keys refused with no transition and no mutation; distinct
slots still yield one transition each) and an RPC control (a duplicate-slot
heartbeat is refused; status and timeline unchanged).
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01's AMEND on #134 (three P2s; the disarm policy is unchanged):
1. Only a ready fact for the watched primary epoch clears or disarms
the watchdog. The full promotion fact is passed and its epoch is
compared with the watched epoch under the watchdog lock, so an
engine still ready at an older epoch (its new assignment refused at
admission) cannot disarm the new assignment, and an assignment that
advances while the fact is read is not cleared by it.
2. The G1 role-admission latch of a primary-assigned replica is checked
before readiness: it reports role_admission_failed for as long as it
holds, whatever an older engine-ready fact says.
3. Health events come from the accepted store mutation itself:
ObservationStore.IngestWithHealthTransitions returns, under the
store lock, each slot whose unhealthy reason the accepted report
changed against the same server's previously stored fact. A refused
report yields none and expiry never fabricates a clear. The master
ingests and records those events under healthMu, so events follow
accepted order across concurrent heartbeats.
Lock order: healthMu -> store.mu (released inside ingest) -> event
ring; nothing else takes healthMu, and neither the store nor the ring
calls back into the host. The watchdog keeps its own mutex and calls
nothing while holding it.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for codex01's AMEND on #134 (three P2s), with the API shape
only (the watchdog takes the promotion fact's epoch; the store can
return accepted health transitions; the master Host has healthMu), the
behavior still as in 845bdc0:
- real host: ready at epoch 2, the epoch-3 primary assignment refused
at admission (peer-set install fails): the engine still ready at
epoch 2 must not disarm epoch 3, which times out; a genuine epoch-3
ready fact clears it;
- real host: a ready primary whose epoch-3 role call fails (G1 latch)
must report role_admission_failed despite its old ready fact; a
successful redelivery clears it;
- master: a second heartbeat landing between the first one's ingest and
its event bookkeeping must leave both events, in accepted order;
- master: expiry during an ingest that reports unhealthy again must not
fabricate a clear;
- control: a refused older heartbeat records nothing.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude05 accepted the disarm rule (21:24Z): after a fresh ready fact
clears it, the watchdog stays disarmed until the next primary epoch or a
new process incarnation. Tests:
- ready, then not ready an hour later on the same incarnation (and the
same assignment replayed): no recovery_timeout;
- a restarted process (new incarnation, same primary epoch) is re-armed
and reports recovery_timeout past the timeout, while the old process
stays disarmed;
- master: a running primary that degrades on the same incarnation (no
unhealthy reason) follows the normal failover rules to the qualified
peer, and nothing is listed as unhealthy.
Doc only otherwise: the watchdog comment names the incarnation re-arm.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Volume: a replica holding the PRIMARY assignment that has not produced
the engine's promotion-ready fact within --recover-timeout (default 30s,
from the primary assignment in this incarnation) reports
Eligible=false with unhealthy_reason=recovery_timeout instead of staying
silently not-ready. The G1 role-admission latch of a primary-assigned
replica reports role_admission_failed. A fresh ready fact clears it
(Eligible=true, reason empty) and disarms the watchdog until the next
primary epoch. Supporting replicas are never flagged; /status shows
their catch-up state (elapsed, lag).
Master: an explicit unhealthy slot is ineligible, so it gets no boot
grace and fails over at once to a peer that passes the promotion
evidence gate; with no qualified peer nobody is promoted. The reason is
listed in QueryVolumeStatus (unhealthy_replicas) and recorded as
replica_unhealthy / replica_unhealthy_cleared events when a slot's
stored reason changes.
wal_corrupt and io_error need typed failures from the durable recovery
path: tracked as a follow-up issue.
Lock order: the watchdog has its own mutex and calls nothing while
holding it; the master's transition check reads the observation store
before and after ingest and appends to the event ring, holding neither.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#128 rule 6 (claude05's rulings 21:07Z): declarations with the decision
stubbed, plus the controls.
- proto: HeartbeatSlot.unhealthy_reason (13); StatusResponse
.unhealthy_replicas (9) with ReplicaUnhealthy (regenerated with the
checked-in generator versions; the gRPC file is unchanged).
- authority: SlotFact/HeartbeatSlot.UnhealthyReason (raw fact).
- volume: the recovery watchdog type and Host wiring (primary
assignment, supporting admission, heartbeat Eligible/UnhealthyReason,
/status UnhealthyReason and CatchUp), --recover-timeout on blockvolume
(default 30s, logged at start); its decision is stubbed here.
- controls: a primary-assigned not-ready replica past the timeout
reports Eligible=false + recovery_timeout; ready clears it and
disarms the watchdog, a new primary epoch re-arms it; the G1 latch
reports role_admission_failed; /status shows the reason and a
supporting replica's catch-up state; the master promotes nobody
without a qualified peer and shows the reason in volume status and as
replica_unhealthy / replica_unhealthy_cleared events. Controls that
pass on both sides: a supporting replica is never flagged; an
unhealthy primary fails over at once to a qualified peer.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every /chunk error is a typed JSON body (B9 codes plus the 2026-11-15
transport errors), except an unknown path, which fell through to
net/http's plain-text "404 page not found". A catch-all /chunk/ route
now answers 404 {"code":"not_found","retryable":false}. The known routes
are unchanged; with the endpoint disabled, /chunk is still not mounted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #130 r5 (one P2): the recovery re-probe triggered on the
newer heartbeat's ReadyForPrimary bit alone. A newer engine-ready but
ineligible, withdrawn or unreachable heartbeat, with the frontend now
ready, led to a re-probe that returned the current primary ready, so
the gate skipped its placeability check and preserved an excluded
primary.
The trigger is now the whole fresh verdict: the newer fact must be
ready and placeable (reachable, eligible, not withdrawn). An excluded
newer fact causes no re-probe, so the first verdict and the gate's
fresh placeability/grace check decide, and the failover stands.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Counter-controls for the review of #130 r5 (tests only, on 6989dfd),
through the real workload-plan provider with the peer query held: the
frontend finishes recovery but the newer heartbeat, though engine-ready,
excludes the current primary (ineligible, withdrawn, unreachable). The
failover must stand; frontend readiness must not preserve an excluded
primary. The recovered-placeable positives and the engine-ready /
frontend-unready counter-control are unchanged.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every reconciliation start and every BeginBaseInstall bumps a generation.
A worker selects slices, records compare results and certifies the dirty
set only while its own generation is current, so:
- a worker running when a BASE install begins can no longer finish over
it and clear the install guard (Base=Installing), in memory or on disk;
finishReconcile also refuses while the guard is set (two independent
guards);
- a worker that saw its set empty, or compared a chunk, before a BASE
install restarted reconciliation can neither certify the replacement
run nor delete from its set.
A replaced run closes its channel, and waitReconciled re-checks against
the current run.
Deterministic schedules (test hook at slice, compare and certify):
- held worker -> BeginBaseInstall -> worker resumes: cuts stay refused
as base_installing, the persisted header keeps Installing, a restart
still refuses;
- old worker paused at certify -> Begin/EndBaseInstall -> old resumes:
the replacement stays reconciling and untouched, cuts refused;
- old worker paused after a compare -> Begin/End -> old resumes: the
replacement set is untouched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recover republishes the dirty map but did not take captureMu, so it could
run inside a quiesced cut: after the cut's Sync fixed H and before its
copy, a same-open Recover could publish a newer complete record (H+1) and
the cut would copy those bytes into a HEAD labelled H. Recover now holds
captureMu shared (order captureMu -> lifecycleMu -> mu), as Write,
WriteBatch, ApplyEntry and WriteExtentDirect do; nothing calls Recover
under captureMu.
Control: a real partial batch pwrite leaves a complete record at H+1; the
cut parks right after its barrier Sync fixed H and starts a same-open
Recover, which waits for the barrier; HEAD at H holds no post-H bytes and
the next cut publishes the recovered bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The typed control codes map every unlisted cause to 500 internal, so a cut
refused while the layer reconciles its dirty set (and a detach whose
deadline ended during reconciliation) reported internal. They now answer
409 with code reconciling, retryable, as ruled for the reconciler.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a layer's dirty set is unknown, its first cut used to hash-compare
every chunk under the capture barrier, which paused writes for a
whole-volume copy. The unknown case is a lost or mismatched bitmap, or
a BASE install that just finished.
Now the layer reconciles in the background, outside the barrier:
- The reconcile set is every chunk with a local copy (an absent chunk
never written locally is HEAD's content).
- A layer-owned reconciler, joined on Close, takes bounded slices. Per
chunk it reads through the normal read path, hashes, and compares
with HEAD; a mismatch sets the chunk's dirty bit. A write racing the
comparison marks its chunk dirty anyway.
- When the set is empty, the dirty set is saved first, then a header
naming HEAD. A crash between the two leaves a mismatching header, so
the next attach reconciles again rather than trusting an incomplete
bitmap. Then cuts resume, uploading only dirty chunks.
While reconciling, no HEAD moves:
- Cut, Capture and MakeRemoteDurable return ErrChunkReconciling
(retryable).
- Detach waits for reconciliation within its deadline, then makes its
normal cut; otherwise ErrChunkReconciling.
- The automatic cut scheduler skips the tick (not a failure, no
backoff).
A fresh host (FreshFromHead) starts with an empty dirty set instead of
an unknown one. Its local volume is new and accepts no write before
attach, so a new volume never reconciles.
Stats gains Reconciling and ReconcileDone/ReconcileTotal. DirtyChunks
(the scheduler's threshold) does not count chunks awaiting
reconciliation.
Test changes:
- The storage fixture waits for reconciliation after attach.
- The BASE tests wait after EndBaseInstall.
- The chunkstore source-host fixtures (including the catalog fork test)
attach as fresh hosts, which is what a new empty volume is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #130 r4 (one P2): the production provider probes the current
primary first, then the peers. If the current primary's frontend
finished recovery and a newer ready heartbeat arrived during the peer
queries, both gates ended its grace but still direct-reassigned from the
probe's outdated Current.Ready=false.
Both gates now go through probePromotionCandidatesCurrent: when the
current primary's own fresh heartbeat advanced to ready (a newer fact or
a new incarnation) while the probe ran and the probe said it was not
ready, the probe is run once more and that fresh result decides. A
heartbeat is never taken as frontend readiness: if the fresh probe still
finds the frontend unready, the failover stands; a heartbeat already
ready before the probe causes no re-probe.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for the review of #130 r4 (tests only, on bb37750), using the
real workload-plan promotion provider over fake /status servers. The
provider probes the current primary first, then the peers; the peer
query is held while the current primary's frontend finishes recovery
and a newer ready heartbeat arrives. The gate must not direct-reassign
from the probe's outdated current verdict (unsupported and supported
paths). Counter-control: a newer engine-ready heartbeat while the
frontend is still unready still fails over.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recover republishes the dirty map outside the write path: a partial batch
append can leave a complete newer record that same-open Recover publishes.
It only invalidated the WAL-sync coverage generation, so a chunk staged
before it could be reused over the recovered bytes. Recover now tells an
attached chunk layer, which counts a mutation of every chunk (O(chunks),
recovery only), also on a failed or partial scan, before s.mu is released
so no read sees recovered bytes first.
Control: stage chunk 0, then a real partial batch pwrite and same-open
Recover before the barrier: HEAD at the recovered H has the recovered
bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #130 r3 (three P2s; the same class as r1/r2, so fixed
structurally rather than per branch):
- Controller: a supported snapshot that carries any superseded slot
fact (older than the newest recorded for that replica, or equal-time
with another incarnation) is a stale snapshot. It records nothing and
no decision branch runs on it (readiness, endpoint refresh, rebalance,
failover, fallback); any existing desired is kept, as for a stale
authority basis. Fresh facts, including fresh unhealthy and expiry
decisions, are unchanged.
- Unsupported-volume gate: the current primary's own fresh slot fact is
recorded for every unsupported volume, before the promotion-reason
allow-list and concrete-placement filters, so ready reports and starts
under any reason are counted. The promotion rules are unchanged.
- Both gates decide after the blocking probe from the current primary's
fresh slot read at that point (primaryBootGraceHoldsNow), so a newer
unhealthy report or a heartbeat that expired during the probe is seen;
the unsupported gate also skips if the authority line moved during the
probe.
Lock order unchanged: state under TopologyController.mu; the gates read
the publisher line and the store snapshot (their own locks, released)
before calling the controller; no new locks.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for the review of #130 r3 (tests only, on 4c84545):
- controller: a delayed READY fact of the previous incarnation with an
obsolete endpoint must not drive an endpoint refresh; after newest B
reported ready, a delayed UNREADY A must not fail over (a fresh
unready B still does);
- unsupported for a reason outside the promotion allow-list
(UnknownReplicaClaim): a ready report and a restart seen then must
still be recorded, so after the reason clears the same incarnation
going unready, or a third start, gets no grace;
- held promotion probe: a newer unhealthy report, or heartbeat expiry
while the grace still runs, during the probe must lead to failover;
an unchanged fresh primary across the held probe keeps its grace.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>