Commit Graph
101 Commits
Author SHA1 Message Date
pingqiu 608046e6cb fix: refuse missing open-only volumes before fresh sidecars 2026-11-19 00:33:10 -08:00
pingqiu 4055e403ea test: cover open-only geometry and disappearance race 2026-11-18 23:38:06 -08:00
pingqiu d102a1c1a3 fix: admit geometry only when creating durable storage 2026-11-18 23:37:14 -08:00
pingqiu 1e5fe198e3 test: preserve existing-volume create-geometry compatibility 2026-11-18 23:36:38 -08:00
pingqiu a9a2cfa936 style: group create-admission imports 2026-11-18 23:10:20 -08:00
pingqiu 9e809120f4 fix: admit original geometry before every durable create 2026-11-18 23:08:47 -08:00
pingqiu c4a37fd4a0 test: cover create admission callers and legacy retry 2026-11-18 23:07:15 -08:00
Ping Qiu 56af794492 Merge pull request #197 from seaweedfs/feat/walstore-format-v3
storage: walstore format bump v3 (#51, #189)
2026-11-18 08:07:17 -08:00
pingqiuandClaude Opus 5.5 6896463a44 volume: name the cause when the workspace lease guard fences
The guard fenced silently: when renewals kept failing until the lease
expired, it drained the volume through blockvolume's lease-stop path, which
logged nothing, and returned the raw RPC error (issue #205).

- Every fence records its first cause: lease expired without a successful
  renewal, expired after a failed renewal (with the renewal's latency and
  error), an invalid reply, a reply that arrived after the deadline,
  revocation by the master, or shutdown. The guard logs it once as
  "workspace lease: fenced ...", FenceCause() returns it, and the non-ACK
  drain error carries it.
- Every failed renewal is logged with its latency and the lease deadline,
  also when the lease is still valid: a run of them is the warning before
  an expiry fence.
- An expiry after a failed renewal returns "workspace lease expired:
  renewal failed after <d>: <err>", wrapping the RPC error.
- blockvolume logs when it stops because the guard requested the drain.

The fence behaviour itself is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 03:50:08 -08:00
pingqiu a81bca4926 feat(storage): activate mapped v3 through the production storage callers 2026-11-18 03:49:47 -08:00
Ping Qiu 72eefdbe28 Merge pull request #174 from seaweedfs/feat/walstore-default-smartwal-experimental
blockvolume: walstore is the default for new volumes; smartwal is experimental
2026-11-16 13:41:15 -08:00
Ping Qiu 248f17017e Merge pull request #162 from seaweedfs/chore/scrub-reviewer-names-in-comments
chore: drop reviewer names and ruling timestamps from code comments
2026-11-16 12:47:54 -08:00
pingqiuandClaude Opus 5.5 ba5eeec356 blockvolume: help and README say auto refuses a walstore-chunk root
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:47:04 -08:00
pingqiuandClaude Opus 5.5 1f10755b0e blockvolume: walstore is the default for new volumes; smartwal is experimental
--durable-impl now defaults to empty (auto). A new volume is created as
walstore. An existing volume opens with the implementation its on-disk
superblock names, so volumes created under the old smartwal default keep
opening (no ImplKindMismatch on upgrade). An explicit selector keeps the
exact ErrImplKindMismatch refusal, and an unrecognized on-disk format is
still refused.

- core/frontend/durable: ImplAuto (the zero value) is resolved per volume
  in openOrCreate; openExisting/createFresh take the resolved
  implementation, and each volume handle records it, so DurableStatuses
  reports the on-disk implementation. ImplSmartWAL is documented as
  experimental; the 'production default' comments are removed.
- cmd/blockvolume: --durable-impl default '' with help text 'auto';
  smartwal (experimental). The walstore-only options still require an
  explicit --durable-impl=walstore.
- README: smartwal listed under 'Not claimed yet' with its open issues.

Tests: auto creates walstore; auto opens existing smartwal, walstore and
parallel-walstore volumes by their on-disk format; auto refuses an
unrecognized file; the flag default is empty; explicit values accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:31:27 -08:00
pingqiuandClaude Opus 5.5 48db2739ec ci: add a test workflow (build, vet, go test -short) and harden dead-port tests
- .github/workflows/test.yml, job 'go test (linux)': on pull_request and on
  push to main; Go from go.mod; go build ./..., go vet ./..., and
  go test -short -count=1 -timeout 10m ./... with CGO_ENABLED=0. Actions are
  pinned by commit SHA, permissions are contents: read, and a new push to a
  PR cancels the older run.
- core/ops/surface_test.go: fix the two go vet warnings (resp used before
  the error check), so vet covers the whole module.
- cmd/blockvolume: a withdrawn port no longer has to answer ECONNREFUSED.
  A successful connect still fails; any other dial error passes only if the
  address can be bound again.
- core/host/volume: probe tests dial a listener they opened and closed,
  not the fixed 127.0.0.1:1.
- core/replication/component: on failure, the G5-5C and G9A catch-up tests
  log frontiers, peer status and the engine trace. Assertions and timeouts
  are unchanged.

Test files and the workflow only; no product code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 11:47:44 -08:00
pingqiuandClaude Opus 5.5 c9273a22be chore: drop reviewer names and ruling timestamps from code comments
Comments in source and tests named individual reviewers and carried the
time a decision was taken (for example "(name's ruling, 06:47Z)"). Those
are review bookkeeping, not design rationale. Remove the names and the
dates/timestamps; keep the rationale, issue and PR references (#51, #82,
#83, #142, #159) and spec section references as plain text.

Comment-only: no code, test logic or string literal changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 11:39:16 -08:00
pingqiu 1bad5dccec Merge main 11f3afe6 into fix/issue51-walstore-midhistory 2026-11-15 23:17:47 -08:00
pingqiuandClaude Opus 5.5 e910449f70 storage: RED controls for the #155 review (detection only)
codex01's review of f8d43653 (V:/share/rdma/codex01-block155-review-
20261116T0644Z/REVIEW.md) and claude05's ruling (A), 06:47Z. Against the
reviewed production code (its replay cutoff and positional smartwal
fail-closed; smartwal warning accessors stubbed so the tests build):

- a damaged STALE record in a released range drops retained, synced
  LSN 3 (TestWALStoreRecoverStaleReleasedGarbageKeepsRetainedData);
- a torn smartwal slot accepted by one recovery becomes wal_corrupt
  after a frontier jump and a new sync
  (TestSmartWALTornSlotSurvivesAFrontierJump);
- a smartwal mid-history hole is an outage instead of a warning
  (TestDurableStartup_Issue51_SmartWALHoleIsAWarningNotAnOutage);
- plus codex01's advisory: a healthy primary stays healthy with a
  warning (TestStatusServer_StatusCarriesRecoveryWarnings..., which
  passes either way: the plumbing never forced health).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 23:04:18 -08:00
pingqiuandClaude Opus 5.5 d2a6a3b02c storage: RED controls for issue #51 (WAL holes)
claude05's rulings (2026-11-16 06:10Z, 06:14Z). Controls with real
corrupted WALs, failing against stubs that restore today's behaviour:

walstore (interim: a power loss must never become an outage):
- (a) a corrupted mid-history synced entry: recovery succeeds to the
  prefix, but no wal_hole_suspected warning, no count
  (TestWALStoreRecoverWarnsOnMidHistoryHole);
- (c) the newer batch wrapped to offset 0 is replayed past a corrupted
  older entry (TestWALStoreRecoverNoReplayPastAHoleAcrossWrappedRanges);
- the durable status and /status carry no warning
  (TestDurableStartup_Issue51_WALStoreHoleIsAWarningNotAnOutage,
  TestStatusServer_StatusCarriesRecoveryWarningsWithoutChangingHealth).
- controls that pass either way: (b) an out-of-order unsynced tail
  recovers, a torn tail recovers.

smartwal (fail closed on a mid-history hole):
- a corrupted committed slot with later valid records starts Ready
  (TestDurableStartup_Issue51_SmartWALMidHistoryHoleIsWALCorrupt);
- controls: the issue's exact mutation is wal_corrupt (ea1faf6a), a
  torn tail recovers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:29:41 -08:00
pingqiu 469edccd04 test: qualify replication exchanges and admitted-operation withdrawal 2026-11-15 22:02:36 -08:00
pingqiu 79b3ee78d5 test: qualify replication exchanges and admitted-operation withdrawal 2026-11-15 21:50:32 -08:00
pingqiu 243f73633f fix: gate replication listeners on assigned replica slots 2026-11-15 21:29:56 -08:00
pingqiu 24cad21474 fix: retain manifest capability and exact root identity through provider cuts 2026-11-15 18:37:33 -08:00
pingqiu ce6e4449d8 feat: expose upload concurrency and retain manifest-aware contract checks 2026-11-15 18:27:57 -08:00
Ping Qiu 4e5da657f5 Merge pull request #136 from seaweedfs/blockc/ublk-frontend-m5
ublk frontend: serve a volume as /dev/ublkbN (io_uring command queues)
2026-11-15 16:42:37 -08:00
Ping Qiu 48fae0300d Merge pull request #139 from seaweedfs/feat/typed-recovery-reasons
volume: report wal_corrupt / io_error from a failed durable recovery at once
2026-11-15 16:42:27 -08:00
pingqiuandClaude Opus 5.5 184f755feb blockvolume, volume: report classifiable open failures too; document io_error
Review of #139 (codex01 AMEND):

1. #133 covers open AND replay. A classifiable EnsureStorage failure now
   takes the same fail-closed path as a replay failure: local readiness
   blocked (frontend I/O refused), the typed reason recorded through
   ReportLocalRecoveryFailure, and the process kept up serving status and
   heartbeats, so a primary assignment reports it at once. An open
   failure that cannot be classified exits as before.
2. io_error is documented as deliberately broad: the volume's local
   storage could not be opened or read at startup. A path error such as
   ENOENT, EACCES or EISDIR is io_error too, which says the storage is
   unusable, not that the disk is physically damaged. The underlying
   error stays in the readiness evidence and is now in the log line.

Refs #133

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:26:36 -08:00
pingqiuandClaude Opus 5.5 1e0e79e236 blockvolume: startup open-and-replay controls through the actual caller (RED)
Review of #139 (codex01 AMEND):

- main's durable open and replay move into openAndRecoverDurable (the
  function main now runs), with the open-path behavior unchanged here:
  any EnsureStorage failure still exits unreported.
- controls driving that function: a classifiable open failure (EIO path
  error; and a real provider whose volume file is truncated, so the magic
  read hits io.ErrUnexpectedEOF) must fault fail-closed and report
  io_error; an unclassified open failure stays fatal with no report; a
  replay failure faults and reports (a real provider's corrupted smartwal
  volume reports wal_corrupt); a clean recovery clears the block.
- classifier controls: ENOENT and EACCES path errors are io_error by
  contract (local storage unusable, not proof of disk damage); a WAL
  integrity fault wrapping a path error stays wal_corrupt.

Refs #133

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:26:36 -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
pingqiuandClaude Opus 5.5 3f73b56f18 volume: typed recovery reasons wiring and controls (RED)
#133 (follow-up to #128 rule 6): wiring with the classifier stubbed,
plus controls.

- volume: UnhealthyWALCorrupt / UnhealthyIOError; LocalRecoveryHealthReason
  (stubbed here: classifies nothing); Host.ReportLocalRecoveryFailure
  records the classified reason, cleared by ClearLocalReadinessBlock; the
  watchdog reports a recorded local failure for a primary-assigned
  replica at once (after the G1 latch, before readiness and the timeout).
- blockvolume: a failed durable RecoverVolume calls
  ReportLocalRecoveryFailure(recErr) next to BlockLocalReadiness.
- controls: the classifier maps WALIntegrity (typed or the sentinel,
  wrapped or not) to wal_corrupt, SubstrateIO / fs.PathError /
  io.ErrUnexpectedEOF / EIO to io_error, and anything else (WALRecycled,
  untyped) to nothing; the real chain (a corrupted smartwal store ->
  durable.Recover -> ReportLocalRecoveryFailure) makes a primary-assigned
  replica report wal_corrupt at once, cleared by a clean recovery; a
  replica that is not primary-assigned is not flagged; an unclassified
  failure reports nothing early and recovery_timeout still covers it.

Refs #133

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:11:04 -08:00
pingqiuandClaude Opus 5.5 ccff48ea29 ublk, volume: request counters and /status/ublk for the fsync gate
The ublk handler counts every received request by kind before the
backend call (reads, writes, FUA writes, flushes, other) and the requests
that completed with an error. blockvolume wires the device as the status
server's ublk source: GET /status/ublk?volume=<id> returns them, as
/status/nvme returns the NVMe target's, so the D0 gate can show every
guest fsync reaching the ublk FLUSH and Backend.Sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:08:56 -08:00
pingqiuandClaude Opus 5.5 11bba8f318 blockvolume: --ublk-device serves the volume as /dev/ublkbN
--ublk-device=N (default -1, off) starts a ublk target for the volume
after the other frontends, with the same block and volume size the NVMe
target uses, and reports {"phase":"ublk-ready","device":"/dev/ublkbN"}.
--ublk-queues and --ublk-queue-depth tune it (defaults 1 and 64). Like
iSCSI and NVMe it auto-enables the readiness bridge, so the device serves
only through a healthy projection. The device closes first on shutdown;
a start failure tears down like an NVMe target failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:08:56 -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
pingqiu 69e9fbc4fe feat: enforce workspace leases in the blockvolume lifecycle 2026-11-15 13:35:18 -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
pingqiuandClaude Opus 5.5 f834a1882e durable: only the timer triggers an automatic cut; a newer success clears a failed-auto backoff; a fenced layer stops its loop
The remote holds snapshots, not live data. Cuts are published at Snapshot,
Detach/stop and explicit Cut, and automatically only by the operator's
timer (off by default). The dirty-chunk count no longer triggers a cut:
the loop runs only with a timer, and the policy has no threshold trigger.

A successful cut of any kind observed after a failed automatic cut makes
that failure's backoff obsolete, so an explicit success followed by the
timer is no longer suppressed until the old retry time. A success older
than the failure leaves the backoff in force.

A fenced layer can never publish again: its loop ends instead of retrying
refused cuts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:54:59 -08:00
pingqiuandClaude Opus 5.5 285d82d699 blockvolume, durable: chunk cut timer off by default; dirty threshold 512 bounds a cut
The remote holds snapshots, not live data: cuts are published at
snapshots, at detach/stop and on explicit request. The periodic timer is
now off by default (operators may set one, e.g. 15m, as a host-loss
safety net) and the dirty threshold is 512 chunks (2 GiB at 4 MiB),
kept only as a bound on one cut's size. Success resets, failure backoff,
no cut with nothing dirty and no cut while reconciling are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:35:16 -08:00
pingqiuandClaude Opus 5.5 022c9077dd durable, blockvolume: automatic cut scheduler (timer + dirty threshold)
The volume's automatic cuts follow the W3 ruling:
- Timer: a cut is due once ChunkCaptureInterval has passed since the
  last successful cut of any kind; an explicit Cut, Snapshot or Detach
  restarts it.
- Threshold: a cut is due once ChunkDirtyThreshold chunks are dirty
  since the last HEAD. Whichever fires first triggers; zero disables
  either.
- Automatic cuts are at least 1 s apart.
- A failed automatic cut resets nothing and is retried after a backoff
  doubling from 1 s to 30 s.
- A successful cut, including a no-op one (no CAS), clears the backoff
  and restarts the timer.

The decision is a pure policy (cutPolicy), tested with explicit times.
The provider loop polls the layer's Stats every 100 ms for the dirty
count and the last successful cut.

blockvolume defaults: --chunk-capture-interval=30s, and a new
--chunk-dirty-threshold=64 (256 MiB of 4 MiB chunks). The --chunk-*
flags stay refused with other implementations when set away from their
defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:35:16 -08:00
pingqiuandClaude Opus 5.5 273ca809d8 durable: a refused observer rebase never leaves I/O open; seed and install serialized
SetWriteObserver published the observer first and only logged a refused
ship-LSN rebase, so the volume kept serving writes its observer would
mis-order.

Now:
- SetWriteObserver rebases an LSN-ordering observer to the store's next
  LSN before installing it. If the rebase is refused, the observer is
  not installed and the error is returned. The backend also records the
  fault and refuses every I/O until an install succeeds, so a later
  attach that marks the volume operational cannot reopen it. blockvolume
  reports the error.
- The frontier seed and its observer rebase run in one critical section
  with observer installs (observerMu). Whichever runs second sees the
  other's result; a seed landing between an install's rebase and its
  publication can no longer leave the observer on the old LSN. A refused
  rebase after the seed records the same fault.
- RebaseShipLSN documents that it moves only the ordering cursor:
  entries already dispatched to peer queues carry lower LSNs and are
  untouched.

The composition test checks the install error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:15:04 -08:00
pingqiuandClaude Opus 5.5 e483d45728 blockvolume: HEAD holder is <server-id>/<replica-id>
The replica id alone made two hosts that both serve replica r1 look like
the same holder returning, so the later one was not fenced (B9 W2
appendix, 2026-11-15 14:30Z). blockvolume now passes
<server-id>/<replica-id> as the provider's ChunkHolder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:11:08 -08:00
pingqiuandClaude Opus 5.5 608f9efbfc blockvolume: --chunk-control-endpoint mounts the /chunk/* routes
Off by default; only with --durable-impl=walstore-chunk and a
--status-addr. The routes are served from the durable provider and the
catalog under --chunk-path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:54:50 -08:00
pingqiuandClaude Opus 5.5 985a825ac5 blockvolume: apply the VOLUME attach rules before the chunk layer attaches
walstore-chunk now dials one filer client for the per-volume remotes and
a catalog under the same --chunk-path, and wires the provider's attach
check to Catalog.EnsureVolume with the local geometry (B9 W2 §4.2, ruling
of 2026-11-15): the first attach creates VOLUME, and an attach is refused
with geometry_mismatch, or with fork_incomplete for a fork whose HEAD is
not written yet. It runs before any HEAD read or CAS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:54:24 -08:00
pingqiuandClaude Opus 5.5 da4fde6747 blockvolume: --durable-impl=walstore-chunk with a SeaweedFS remote
walstore-chunk is opt-in and needs --durable-root and --chunk-filer.
Each volume's HEAD and key bindings live under --chunk-path/<volume-id>
(the volume id must be one plain path element); --chunk-collection and
--chunk-replication apply to chunk needles, and --chunk-capture-interval
runs periodic cuts while healthy (0: on demand only). The --chunk-*
flags are refused with any other implementation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:16:39 -08:00
Ping QiuandClaude Opus 5.5 b1871160e0 Fence the dual-lane rebuild port with the replica admission rules (#85)
* test: red test for the unfenced dual-lane rebuild port

A host fenced as primary still accepts base blocks on the dual-lane
port. Expected to fail until the port is fenced (#84).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fence the dual-lane rebuild port with the replica admission rules

The dual-lane port applied base blocks and WAL entries with no epoch or
role check. SessionStart now carries the sender epoch, and the
production ReplicaBridge asks ReplicaListener on SessionStart and each
mutating frame: no frame on a primary, below the floor, with epoch 0,
or before the role is known. A higher epoch is persisted first, and a
fence waits for frames already admitted.

The SessionStart frame grows from 28 to 36 bytes, so both ends of a
dual-lane rebuild must run this version.

Fixes #84

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* keep BaseDone and BarrierReq inside the dual-lane counted section

BaseDone released admission before MarkBaseComplete advanced the
frontier, so a fence could return while that mutation was pending.
BarrierReq was not gated, so a fenced replica could still answer it.
Both now stay inside the section; the barrier holds it until its
response is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* end the barrier section before its reply

A fence drains effects, not network writes: holding the barrier
section through BarrierResp let a peer that does not read make
FenceAsPrimary time out after every effect had finished. The section
now covers the sync and the completion check, and ends on every path
before the reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 22:40:52 -08:00
Ping QiuandClaude Opus 5.5 2e204b533c fix(G1): persist the replica epoch floor across restarts (red test first) (#83)
* test(G1): red - a restarted replica applies a ship below its acknowledged epoch

fencing-gaps-todo.md G1, red test first, as the doc describes it: a
listener accepts a ship at epoch 2, is stopped and restarted on the same
store, and a ship at epoch 1 arrives. Today it is applied: the floor was
in memory only.

Adds the seam the fix uses: NewReplicaListenerWithFloor(addr, store,
floorPath), which cmd/blockvolume now uses with
<durable-root>/<volume-id>.replica-floor (empty for memback). floorPath
is ignored in this commit, so the test is red on behaviour.

Stacked on the G2 branch (it reuses G2's epoch floor).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G1): a durable replica epoch floor, and no mutation before the role is known

fencing-gaps-todo.md G1, per the plan accepted on #83 (claude03; codex01
rounds 1-3).

- core/transport/floor.go: a versioned, volume-bound floor record,
  strictly decoded (unknown/duplicate/missing fields, trailing data, wrong
  schema or volume, over 4 KiB refuse); persisted by temp write+fsync,
  rename, directory fsync, each checked; InitReplicaFloor creates the
  bootstrap record (epoch 0) before the volume and never replaces one.
- Listener: NewReplicaListenerWithFloor(addr, store, volumeID, floorPath)
  loads the record (missing or invalid refuses) and starts unassigned:
  every mutating frame is refused until a role call succeeds. A frame
  whose epoch raises the floor persists it inside its G2-counted section
  before any effect or ACK (a barrier too); serialized under floorMu and
  monotonic; a refused frame leaves the lineage unchanged.
  FenceAsPrimary drains, persists, then returns; AdmitAsReplica persists
  first; both return the error.
- Host: AdmitAsReplica errors fail the supporting path closed; any failed
  role call sets an admission latch that makes the projection unhealthy
  (writes refuse even on a prior-healthy host), reported in /status;
  a later successful role call clears it. SetSelfFence returns the
  replay error and cmd/blockvolume then does not serve.
- cmd/blockvolume: the floor record is created before a new volume
  (DurableProvider.VolumeExists), and required on every later start.

Tests: the red test, revised to the accepted 3-phase form (epoch-2
barrier ACK; restart refused before assignment; a stale epoch-1
admission still refuses epoch 1; current epoch accepted), barrier-only
restart, fresh restart before assignment, record negatives and the
existing-empty missing-record refusal, per-step persist failures on
ship/barrier/rebuild, role-call persist failure incl. after a drain,
fence-then-crash, concurrent monotonic raises, probes never persist, and
the admission latch through the real StorageBackend. Each mechanism is
load-bearing: without persistence 5 tests fail, without the startup gate
2, without the latch 1. Ledger: INV-FENCE-FLOOR-DURABLE-001.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G1): stale role replays never reconcile a newer failure; the floor record's key set is closed

codex01 review of 66446e0:
- R1: a stale successful role call (e.g. an epoch-2 replay after the
  epoch-3 persist failed) cleared the admission latch and reopened
  writes. The host's desired role is now monotonic in epoch: a role call
  below the current desired epoch is refused as stale, without
  replacing the desired role or touching the latch; only the current (or
  a newer) epoch's success clears it, and install replay targets the
  retained current role.
- R2: encoding/json struct decoding accepted case variants, so
  {"epoch":7,"EPOCH":0} loaded as floor 0. The key check now runs before
  decoding and accepts exactly schema, volume_id and epoch, case-sensitive,
  none repeated.

Red (66446e0's floor.go and host.go) / green: codex01's two controls;
the stale-replay cases on the primary, supporting and install-replay
paths; uppercase keys, case-folded duplicates in both orders and a
case-folded schema key refuse; canonical epoch 0 stays valid. All 23
G1/G2 tests pass 3/3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 08:44:36 -08:00
Ping QiuandClaude Opus 5.5 cb353bccea fix(G2): a new primary fences its own replica listener (#82)
* test(G2): red - a promoted host applies the deposed primary's ship

fencing-gaps-todo.md G2, red test first. A real ReplicaListener and the
real Host.applyFact primary path: ship at epoch 1 to listener B, master
promotes B to primary at epoch 2 (a self AssignmentFact), the old primary
ships at epoch 1 again. Today the ship is applied.

Adds the seam the fix uses: Host.SetSelfFence / fenceSelf call the
host's own listener on the primary path (after UpdateReplicaSet, before
OnAssignment) and on the supporting-replica path, and replay an already
adopted role when the listener is installed later (cmd/blockvolume wires
it before Serve). The listener's FenceAsPrimary / AdmitAsReplica are
no-ops in this commit, so the test is red on behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G2): a new primary fences its own replica listener

fencing-gaps-todo.md G2. The replica listener gets an epoch floor and a
primary flag. FenceAsPrimary(e), called by the host on the primary path
before OnAssignment, sets the floor to at least e and refuses every
replication mutation; AdmitAsReplica(e), on the supporting-replica path,
re-admits replication but keeps the floor. acceptMutationLineage, the
single gate for ship, recovery lane start and rebuild block/done,
applies both. Probes are unchanged.

Green: TestG2_PromotedHostRefusesShipFromDeposedPrimary (real
Host.applyFact primary path + real listener) passes 3/3; new listener
tests: a primary refuses ship / recovery lane start / rebuild but answers
probes; the floor stays after AdmitAsReplica and never goes down.
Ledger: INV-FENCE-SELF-ON-PROMOTE-001.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style(G2): gofmt replica.go field alignment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G2): the fence drains replication mutations already past the gate

Review of cc884db (claude03 P2-1, codex01 P1): acceptMutationLineage
released r.mu before the store write, and FenceAsPrimary only flipped
flags, so a deposed-epoch ship or rebuild admitted just before promotion
was applied after the fence returned, while the host served as primary.

Each mutating frame (ship, recovery lane start, rebuild block, rebuild
done, barrier) is now counted under r.mu from before its gate check until
its storage effect is done; its ack is written after it is uncounted, so
the fence never waits on the network. FenceAsPrimary sets primary and the
floor (no new admissions), then waits for the count to reach zero, bounded
(10 s); on timeout it returns an error and the host fails closed: no
OnAssignment, as for an UpdateReplicaSet failure; master redelivers.

Lock order: Host.selfFenceMu -> ReplicaListener.mu, never the reverse;
r.mu is held only for gate state and the counter (Cond.Wait releases it),
never across storage or network calls.

Red (fence without the wait) / green: in-flight controls for ship (direct
and ApplyHook paths) and a rebuild base write fail, then pass 3/3; a
mutation stuck past the bound makes the fence report an error; the host
does not adopt primary when the fence fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 00:49:38 -08:00
pingqiu 46aa2e122d obs: profile mounted NVMe write phases 2026-08-01 04:18:38 -07:00
pingqiu 8f8d369746 phase167: add opt-in parallel WAL candidate 2026-07-29 20:04:44 -07:00
pingqiu 0dce26d2b0 phase165: add kubernetes nvme rdma publish attach 2026-07-18 03:03:54 -07:00