Commit Graph
1079 Commits
Author SHA1 Message Date
pingqiuandClaude Opus 5.5 56300cc6c1 chunkstore: attempt-bound retention, fork holds, rolling windows
- Retain deletes the exact attempt it planned: the attempt's entry is
  marked deleting conditionally and the name record is removed only
  while it names that attempt; a replacement is reported as replaced.
- Fork records a hold (forkholds/<name>/<attempt>/<target>) before it
  reads the parent. Retain marks first, then reads the holds: a live
  hold reverts the mark (fork_held); a fork holding after that read
  finds the attempt deleting and refuses before installing anything.
  A hold counts while its target has no HEAD and its VOLUME records the
  fork, or while it is younger than the operation deadline.
- A pass stopped after a mark finishes (or reverts) it on the next run.
- Log-spaced keeps use rolling windows anchored at now.
- Exclusive bytes resolve "@owner/key" refs and count every volume's
  HEAD and live snapshots as holders; documented as eligible for GC
  subject to its grace period and intents.
- Retain reports confirmed deletions, the failing snapshot (uncertain
  or not) and what it never reached; the CLI prints them with the
  error and exits nonzero.
- chunkControl.Snapshot validates the class before any cut;
  invalid_class and invalid_policy map to 400.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:36:46 -08:00
pingqiuandClaude Opus 5.5 23d125daa7 chunkstore: RED controls for the retention review
Controls for the six review findings on retention, failing against
stubs that restore each old behaviour:

- a same-name pinned replacement made after planning is deleted
  (retain deletes by name);
- a fork that starts after the scan loses its parent; a stale hold;
  a fork after the hold check;
- log-spaced keeps use calendar periods (10:20 and 09:50 both kept
  at 10:30 with keep-hourly 1);
- exclusive bytes ignore a fork's "@owner/key" holders;
- a failing pass discards its partial result (catalog and CLI);
- an invalid class cuts before it is refused, and maps to 409.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:36:46 -08:00
pingqiuandClaude Opus 5.5 4e5ff2cc95 chunkstore: snapshot retention and space accounting
claude05's rulings (2026-11-15 22:53Z).

Retention, policy on the VOLUME entry: keep the newest KeepNewest
unpinned snapshots, every pinned snapshot not yet past its ExpiresAtNs,
every snapshot younger than KeepYounger (a future creation time from
clock skew counts as young), the newest snapshot of each of the last
KeepHourly / KeepDaily / KeepWeekly periods, and every snapshot a fork
still needs (named by a fork whose HEAD is absent or aborted). Everything
else is deleted through DeleteSnapshot (attempt-scoped tombstones; HEAD
untouched; names freed); GC reclaims the chunks. Equal creation times
rank by name. Semantic and labeled snapshots are not exempt; a pinned
snapshot past its expiry is unpinned. Defaults: 10 newest, 1h. A dry run
plans and writes nothing. The policy is stored as extended attributes on
the VOLUME entry, conditional on a revision.

Accounting, from manifests and filer listings (no data reads; a chunk is
ChunkBlocks x BlockSize, the last clipped): live bytes from HEAD;
per-snapshot exclusive bytes (referenced by no other holder); stored
bytes from the volume's chunk-key bindings, exact for referenced keys
and a full chunk (an upper bound, flagged) for the rest. The
unreferenced-not-yet-collected bytes come from GC's preview once #140
merges; bytes uploaded since creation need a counter (follow-up).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:08:17 -08:00
pingqiuandClaude Opus 5.5 81e0ea7392 chunkstore, volume, sw-block: snapshot retention and space accounting surfaces (RED)
claude05's rulings (2026-11-15 22:53Z): the surfaces and the controls,
with the behavior stubbed (the planner keeps everything, the policy is
not stored, usage reports nothing, no fork needs a parent, the class is
neither validated nor stored).

- chunkstore: snapshot class (semantic / pinned) on the snapshot;
  RetentionPolicy stored on the VOLUME entry (extended attributes, CAS on
  a revision); planRetention / Retain [dry run]; Usage (live, per-snapshot
  exclusive, stored bytes).
- volume: GET /status/chunk?volume= (usage and policy); the snapshot
  route carries "class".
- sw-block: ops chunk usage, ops chunk retain [--dry-run | --set-policy
  --keep-*], snapshot --class / --pin / --expires.
- controls: policy edges (newest N with name tie-break; pinned never
  expired by count or age but unpinned past its expiry; semantic and
  labeled snapshots not exempt; younger than T and clock skew; hourly
  buckets; fork parent), an agent checkpointing every step stays bounded,
  dry run writes nothing, retain keeps N + pinned and frees names, the
  policy CAS, class validation, an incomplete fork's parent kept, usage
  from manifests; CLI usage/retain; and a real-service test against
  SeaweedFS (chunkstore_integration, CHUNKSTORE_WEED): N+5 snapshots plus
  pinned ones -> retain leaves N + pinned, accounting follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:08:17 -08:00
Ping Qiu baca5fd3a9 Merge pull request #137 from seaweedfs/fix/nvme-listener-readiness
fix: report frontend ready only after NVMe listener starts
2026-11-15 14:23:16 -08:00
Ping Qiu fd7da7a760 Merge pull request #134 from seaweedfs/feat/recovery-watchdog
volume, master: recovery watchdog reports an explicit unhealthy fact
2026-11-15 14:08:02 -08:00
pingqiu 9b4d8e1598 Merge remote-tracking branch 'origin/main' into feat/recovery-watchdog
# Conflicts:
#	cmd/blockvolume/main.go
2026-11-15 14:06:21 -08:00
pingqiu f1c7cca9f1 fix: defer presented NVMe readiness until listener startup 2026-11-15 14:05:13 -08:00
Ping Qiu 4f1cb20150 Merge pull request #138 from seaweedfs/fix/testops-backslash-run-id
fix: reject backslash run IDs on Linux
2026-11-15 14:03:25 -08:00
Ping Qiu 95e32afc8a Merge pull request #135 from seaweedfs/feat/blockvolume-workspace-lease
feat: self-fence workspace blockvolume on lease loss
2026-11-15 14:03:17 -08:00
Ping Qiu e93bb40fa2 Merge pull request #132 from seaweedfs/fix/workspace-move-same-replica
workspace: preserve logical replica identity during moves
2026-11-15 14:03:08 -08:00
Ping Qiu 3598e518f8 Merge pull request #131 from seaweedfs/fix/chunk-unknown-path-json-404
volume: answer an unknown /chunk/* path with a typed JSON 404
2026-11-15 14:03:01 -08:00
pingqiu 867b2d8eed fix: reject backslash run IDs on every platform 2026-11-15 13:52:53 -08:00
pingqiuandClaude Opus 5.5 e3a0495003 authority, master: refuse a report that names the same slot twice
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>
2026-11-15 13:51:25 -08:00
pingqiuandClaude Opus 5.5 d44bae2eea authority, master: duplicate slot keys in one report must be refused (RED)
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>
2026-11-15 13:46:33 -08:00
pingqiu a42b54235c fix: make workspace host fencing terminal across guard installation 2026-11-15 13:43:46 -08:00
pingqiuandClaude Opus 5.5 774dee5403 volume, master: bind watchdog readiness to the watched epoch, G1 first; derive health events from the accepted ingest
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>
2026-11-15 13:39:10 -08:00
pingqiuandClaude Opus 5.5 31db16dbb3 volume, master: watchdog review controls (RED)
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>
2026-11-15 13:36:25 -08:00
pingqiu 69e9fbc4fe feat: enforce workspace leases in the blockvolume lifecycle 2026-11-15 13:35:18 -08:00
pingqiuandClaude Opus 5.5 845bdc0a63 volume, master: watchdog disarm and incarnation re-arm controls
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>
2026-11-15 13:25:46 -08:00
pingqiuandClaude Opus 5.5 81575168cc volume, master: recovery watchdog reports an explicit unhealthy fact (#128 rule 6)
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>
2026-11-15 13:20:13 -08:00
pingqiuandClaude Opus 5.5 4a7e00dc99 volume, master: recovery watchdog declarations and controls (RED)
#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>
2026-11-15 13:16:43 -08:00
pingqiu 2427e765e2 test: keep clean move precondition negatives on the same replica 2026-11-15 13:13:50 -08:00
pingqiu 38ad04b42f fix: preserve logical replica identity across workspace moves 2026-11-15 13:04:43 -08:00
pingqiuandClaude Opus 5.5 4137710c6b volume: answer an unknown /chunk/* path with a typed JSON 404
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>
2026-11-15 13:04:05 -08:00
pingqiuandClaude Opus 5.5 1bc9251c0c volume: an unknown /chunk/* path must answer a typed JSON 404 (RED)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 13:03:43 -08:00
Ping Qiu 77ba7a3612 Merge pull request #130 from seaweedfs/fix/primary-boot-grace
authority: keep a restarted primary through one bounded boot grace
2026-11-15 13:01:52 -08:00
Ping Qiu f7ec7b0999 Merge pull request #124 from seaweedfs/blockc/chunk-reconcile-w3b
storage, durable: reconcile an unknown dirty set in the background; no HEAD moves meanwhile
2026-11-15 13:01:44 -08:00
Ping Qiu 71a4d33a02 Merge pull request #118 from seaweedfs/blockc/chunk-cut-scheduler-w3
durable, storage: automatic chunk cuts (timer + dirty threshold) with cut stats
2026-11-15 13:01:31 -08:00
Ping Qiu 46810e1c48 Merge pull request #127 from seaweedfs/test/duallane-pushlive-seal
component: push-live-during-rebuild test accepts the production caller's race outcomes
2026-11-15 13:01:22 -08:00
Ping Qiu 4ba41fe0db Merge pull request #125 from seaweedfs/test/conformance-post-close-ack
conformance: a completed session reaches healthy only after its post-close durable ack
2026-11-15 13:01:14 -08:00
Ping Qiu 1055ba0d91 Merge pull request #129 from seaweedfs/fix/legacy-post-close-durable-ack
transport: legacy catch-up and rebuild send the post-close durable ack
2026-11-15 13:01:05 -08:00
Ping Qiu 74617bdd9a Merge pull request #126 from seaweedfs/fix/gc-composed-head-fixtures
test(gc): preserve HEAD frontier in reachability fixtures
2026-11-15 13:00:56 -08:00
pingqiuandClaude Opus 5.5 e5f0c4728e master: re-probe only on a ready AND placeable newer current fact
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>
2026-11-15 12:42:50 -08:00
pingqiuandClaude Opus 5.5 67dedbe047 master: boot-grace r5 review counter-controls (RED)
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>
2026-11-15 12:38:43 -08:00
pingqiuandClaude Opus 5.5 7b7877e16f storage: reconciliation is owned by a generation; a BASE install supersedes a running worker
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>
2026-11-15 12:31:49 -08:00
pingqiuandClaude Opus 5.5 3dfb612a80 storage: Recover holds the capture barrier shared, like a write
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>
2026-11-15 12:31:49 -08:00
pingqiuandClaude Opus 5.5 df06318ef9 volume: a /chunk operation refused while reconciling answers 409 reconciling
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>
2026-11-15 12:31:49 -08:00
pingqiuandClaude Opus 5.5 b88e7f6997 storage, durable: reconcile an unknown dirty set in the background; no HEAD moves meanwhile
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>
2026-11-15 12:31:49 -08:00
pingqiuandClaude Opus 5.5 6989dfd838 master: re-probe when the current primary reports ready during the promotion probe
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>
2026-11-15 12:27:43 -08:00
pingqiuandClaude Opus 5.5 b2e79c8457 master: boot-grace r4 review controls through the production probe (RED)
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>
2026-11-15 12:23:32 -08:00
pingqiuandClaude Opus 5.5 81f05c9f08 storage: Recover counts a mutation of every chunk, so no staged pre-copy is reused across it
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>
2026-11-15 12:11:08 -08:00
pingqiuandClaude Opus 5.5 bb377502ea authority, master: filter superseded facts once at ingestion; record every unsupported pass; decide after the probe
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>
2026-11-15 12:10:10 -08:00
pingqiuandClaude Opus 5.5 3acab5b0c8 authority, master: boot-grace r3 review controls (RED)
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>
2026-11-15 12:06:07 -08:00
pingqiuandClaude Opus 5.5 b91b2bf3b3 storage: a staged chunk is reused only while its mutation count is unchanged; a barrier Sync failure settles staged intents
The chunk's highest write LSN is not a change detector: a replica apply
may land a block at an LSN below another block of the same chunk, so the
maximum does not move and a stale stage could be reused. Each chunk now
has a mutation count, raised after every dirty-map insert (a write, a
batch write, a replica apply at any LSN) and every BASE block; flushing
moves bytes without changing them and never counts. It is an atomic
per-chunk counter on the write path (O(1), lock-free), sampled before the
staging read and compared at the barrier.

A barrier Sync failure after staging is a clean abort: the cut's staging
intents are deleted (a failed delete is kept and retried by the next cut).

Real-caller controls:
- chunk 0 holds a@10 and b@5; after the staging read, ApplyEntry(b, 6)
  through the production apply path, in the WAL and flushed: HEAD at H
  has b@6;
- staged uploads, then the local fsync fails at the barrier: no intent
  is left; with the intent delete failing too, the intent is kept and the
  next cut settles it and publishes the exact image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:52:01 -08:00
pingqiuandClaude Opus 5.5 4c84545c84 authority, master: decide boot grace from the newest fact; record unsupported ready ticks; cap at the effective window
Review of #130 r2 (three P2s):

- The unsupported-volume gate records the current primary's own fresh
  slot fact on every pass (RecordPrimaryBootFact), not only when a
  promotion is considered, so a ready report ends the grace and ready
  restarts count toward flap history.
- The grace decision is ordered like the history: a superseded fact
  (older than the newest recorded one, or equal-time with another
  incarnation) is not a decision input. The decision follows the newest
  recorded fact (its incarnation, placeability and grace clock), and a
  superseded fact's endpoint is never used for a refresh. A fresh fact
  still needs to be placeable and not ready.
- The cap uses the observation store's effective freshness window
  (FreshnessConfig.EffectiveFreshnessWindow), so an omitted window caps
  at its 10s default; an unset or nonpositive grace takes the window.

Lock order unchanged: state under TopologyController.mu; the gate reads
the store snapshot (its own lock, released) before calling the
controller; no new locks.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:50:53 -08:00
pingqiuandClaude Opus 5.5 7c30c14950 authority, master: boot-grace r2 review controls (RED)
Controls for the review of #130 r2 (tests only, on b5a23c2):

- unsupported path, full product tick: a READY tick (probe says the
  current primary is ready) must still record the fact, so unready again
  in the same incarnation fails over; and ready restarts count toward
  flap history, so a third start gets no grace;
- controller: a delayed UNREADY fact of the previous incarnation, and an
  equal-time fact with a changed incarnation, must not defeat the
  restarted primary's grace;
- cap: an omitted freshness window is the effective 10s default and caps
  an explicit 5m grace; a nonpositive grace takes the window.

The unsupported tests now use a switchable promotion probe.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:47:07 -08:00
pingqiuandClaude Opus 5.5 b5a23c2191 authority, master: order boot facts, honor the grace on the unsupported path, cap it
Review of #130:

- P1: the unsupported-volume promotion gate reassigned directly even
  when only a different slot was stale. It now judges the current
  primary from its own fresh heartbeat slot in the observation store
  (FreshSlotCandidate, server reachability/eligibility folded in) and
  skips the direct reassign while that slot is placeable and inside its
  boot grace. Placement-synthesized facts are never used for it.
- P2: boot history is ordered by observation time. A fact changes the
  incarnation, start count, or ready latch only if its ObservedAt is
  strictly newer than the last recorded one for that replica, so a
  delayed or superseded snapshot (or an equal-timestamp replay) never
  counts a start nor resets or ends a grace. Both gates go through
  PrimaryBootGraceHolds, which records the fact under the same rule and
  evaluates it.
- P2: a configured PrimaryBootGrace above the freshness window is
  capped at it (logged), never widened.

Lock order: boot-grace state stays under TopologyController.mu and the
new code adds no call out of it (existing paths call the authority
reader under c.mu, unchanged). The gates call PrimaryBootGraceHolds and
read the observation store's snapshot (its own lock, released before
the controller call) while holding no host lock. No new locks.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:36:55 -08:00
pingqiuandClaude Opus 5.5 8dcf498997 authority, master: boot-grace review controls (RED)
Controls for the review of #130, on 6c00734 with declarations only
(ReplicaCandidate.ObservedAt copied by the snapshot builder; a
PrimaryBootGrace() accessor):

- full product tick on the unsupported-volume path: the third server's
  facts age out (StaleObservation) while the current primary reports a
  fresh, placeable, restarted, not-ready slot. Today the gate reassigns
  directly inside the grace;
- an ineligible restarted primary still fails over at once (control);
- a configured grace above the freshness window is capped, and an
  unready primary fails over at the capped limit;
- an out-of-order snapshot carrying the previous incarnation's older
  fact, and an equal-timestamp fact, must not change boot history.

The controller rig now advances its clock after the steady fact, so
every later fact is strictly newer.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:34:43 -08:00
pingqiuandClaude Opus 5.5 5792d1427b storage, durable: bound a cut's barrier copy by pre-copy staging
Ruling (B9 W3 bound): the dirty threshold, now the layer's BarrierBound,
bounds how many chunks a cut copies under its barrier; it never triggers
a cut.
- While more candidates than the bound would be copied, the cut stages up
  to the bound per round outside the barrier: current bytes, compared to
  HEAD, uploaded under fresh content keys named by an intent written
  before the round's first upload.
- Each staged chunk records its version: the chunk's highest write LSN,
  flushed or still in the WAL, taken before the read. Flushing never
  changes it; any later write raises it, so a stale stage is never used.
- At the barrier a staged chunk stands for the copy only while its
  version and HEAD are unchanged; the rest is copied, so the image at H
  is exact.
- At most three staging rounds; then the barrier copies the rest
  (correctness over pause), counts BarrierOverBound and reports the
  barrier copy size (BarrierCopyChunks).
- Every intent of the cut (staging rounds and the barrier) is settled
  with it: deleted after the confirmed CAS or a clean abort, kept with an
  unresolved proposal. Superseded staged keys stay under their intent
  until then.
- Snapshot, explicit Cut and Detach's final cut share the path.
The barrier copy and staging share one readChunk helper. The provider
passes ChunkDirtyThreshold (default 512) as the bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:28:34 -08:00