Files
seaweedfs/seaweed-block/docs/maintenance-admission.md
T
Ping QiuandClaude Opus 5.5 a5686e7fa7 Sync seaweed-block v1.1.1 into seaweed-block/ (#13411)
Brings seaweed-block main (v1.1.1 plus the docs and a test fix after it)
into seaweed-block/ as one commit. Only files under seaweed-block/ change,
and the subtree equals seaweed-block main exactly. The module's full
history stays in the seaweed-block repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 19:04:53 -08:00

5.6 KiB

Maintenance admission boundaries

Admission is process-local scheduling for one BCatalog and a full volume identity. It never adds an activity-idle guard or replaces a holder check, session, conditional HEAD write, or conditional Mark/Delete. Retain and legacy snapshot deletion remain legal during ActClean in the kernel.

Publisher entries

A publisher is a same-catalog non-cleaner HEAD publication, including one the kernel permits during cleaning. Register for an acquisition or one bounded publication, never for the surrounding multi-step operation.

Entry Registration lifetime
LayoutRemote.beginSessionLocked session acquisition, after cancelling and joining its own cleaner
BCatalog.Retain each individual RunRetireSnapshot; planning and other retirements hold no interest
BCatalog.DeleteSnapshot one legacy delete transition
BCatalog.RunSnapshotDeleteOperation its publishing store registers each read/compute/CAS transition; receipt reads, receipt settlement, callbacks and intent staging hold no interest
BCatalog.Restore publishing store views register each source or target transition; root copying and dependency enumeration hold no interest
BCatalog.ReleaseTarget each source/target transition
BCatalog.DeleteVolume each target or discovered source transition; object enumeration and reclamation hold no interest
BCatalog.CleanSnapshotDeletePage one bounded intent-page continuation
LayoutRemote.Clean intent loop one bounded intent-page continuation at a time, before opening clean activity

publishingStore is a shallow view with shared backends and counters. Its optional BeginHeadPublication hook is called by runTransition before reading HEAD and released after the single compute/CAS, no-op or error. UpdateHead does not register again. Waiting only at CAS would make the read generation stale when the preceding clean batch closes. The hook does not retry or change an externally supplied expected base; an already prepared intent can still refuse a stale base and must be resumed through its original caller protocol. Plain Store views remain unchanged for low-level/authority users. Multi-volume operations never hold several admissions while copying or enumerating; each publication releases before the next one. The scheduling state per volume is O(1).

Clean entries and transfer

Entry Admission lifetime
LayoutRemote.Clean initial RunBeginClean acquired outside the remote mutex, before initial activity
RemoveUnreachableAll initial endCleanBatch releases initial admission after durable close/settlement, before any page admission
optimistic and armed page batches before Begin until close/settlement

The initial lease uses sync.Once; the remote defers the same release for errors and non-catalog callbacks. Publisher and clean acquisition never nest. No storage call runs with the admission mutex held. Cancellation withdraws the publisher mark.

A3: a synchronous reference-removing call carrying this exact live batch context is unregistered, rather than waiting on itself. SnapshotRemoval monotonicity keeps the cached superset safe; an armed batch's held-generation check fails safe after such a publication. The original kernel checks remain unchanged. The callback is not given layout authority. A released context cannot bypass a later batch. A callback holding a different volume's clean lease does not wait on a held clean admission; it returns retryable layout_busy.

Explicit scope and liveness assumptions

  • A2: publisher preference is not FIFO. Cleaning liveness assumes registrations do not overlap continuously. An overlapping stream can delay an armed batch; no unsafe effect follows, and its maintenance window can end the pass.
  • Other processes/catalogs (offline CLI or another holder) have no shared waiter; they retain typed layout_busy and their own command window.
  • Authority transitions (claim, fence, takeover), rollback and stop settlement are outside scheduling. Stop first joins maintenance. Cleaner-owned activity writes, non-publishing calls and direct low-level users are also excluded.
  • Fresh volume creation has no attached cleaner. No new exclusive-create retry is introduced.

Controls

TestMaintenanceRetainPublisherPrecedesANewCleanPass pauses the individual retirement after it registers: a real new LayoutRemote.Clean must let it publish first, then transfer initial admission to real catalog page batches. TestMaintenanceRetainPlanningDoesNotRegister proves planning does not hold the mark. TestMaintenancePublishingStoreScopesOneConditionalWrite proves reads and plain stores remain unregistered, a read/compute/CAS publication waits and registers, and its interest ends on return. Existing delete-during-clean and released-token controls preserve A3 and the original kernel semantics. These native controls do not claim Linux/race or scale qualification.

TestMaintenanceReleasePublicationReadsAfterBatchClose opens a real clean activity, then starts the real dependent-release kernel transition. It must wait before reading HEAD, survive the close's generation advance, and remove the dependent successfully. The old CAS-only registration fails this control with ErrPrecondition. No stale-proposal retry is introduced.

The A3 control observes the publisher count INSIDE the actual backend HEAD CAS, so a transient register/release cannot pass it. TestMaintenancePublisherInterestHeldThroughBackendCAS pauses the actual backend CAS and asserts a next clean batch cannot enter until that call returns. Both a transient-A3-registration mutant and a release-just- before-CAS mutant fail their named controls.