From e7ce492813315e68c19a2e6a6e06c6ddafe19ecb Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 29 Nov 2026 10:46:51 -0800 Subject: [PATCH] fix: warn on disposable probe cleanup failure without refusing startup --- .../core/frontend/chunkstore/startup_head_probe.go | 7 ++++--- seaweed-block/docs/design/invariants.md | 2 +- seaweed-block/docs/standalone-deployment.md | 10 +++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/startup_head_probe.go b/seaweed-block/core/frontend/chunkstore/startup_head_probe.go index 24c6e6a6fe..c3292e6eb9 100644 --- a/seaweed-block/core/frontend/chunkstore/startup_head_probe.go +++ b/seaweed-block/core/frontend/chunkstore/startup_head_probe.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "log" "path" "time" @@ -15,7 +16,7 @@ import ( // conditional HEAD update contract. The probe touches only its fresh directory. var ErrConditionalHead = errors.New("chunkstore: conditional HEAD startup probe failed") -func (c *BCatalog) checkConditionalHead(ctx context.Context) (result error) { +func (c *BCatalog) checkConditionalHead(ctx context.Context) error { ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() id, err := layout.NewVolumeID() @@ -37,11 +38,11 @@ func (c *BCatalog) checkConditionalHead(ctx context.Context) (result error) { cleanup, done := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) defer done() if err := c.f.DeleteEntry(cleanup, root, layout.HeadName, nil); err != nil { - result = errors.Join(result, fmt.Errorf("%w: cleanup %s/HEAD: %v", ErrConditionalHead, root, err)) + log.Printf("chunkstore: WARNING conditional HEAD probe cleanup failed: leftover=%q error=%v", root, err) return } if err := c.f.DeleteEntry(cleanup, path.Dir(root), path.Base(root), nil); err != nil { - result = errors.Join(result, fmt.Errorf("%w: cleanup empty %s: %v", ErrConditionalHead, root, err)) + log.Printf("chunkstore: WARNING conditional HEAD probe cleanup failed: leftover=%q error=%v", root, err) } }() // The exclusive create installed generation 1. No other actor knows this diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 5be59164fd..6f356a402c 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -831,7 +831,7 @@ Notes: | `INV-WS-STALE-LOCAL-ROOT-001` | An old or rolled-back local root is refused by `layout.Start` before serving; synchronous and deferred attach end without retry and report the typed stale-root error and cure. A fresh root at its own epoch likewise ends with `ErrMissingLocalRoot` and its cure. | M4 Claiming → Refused | `core/frontend/durable/provider_layout.go` `startLayoutRoot`; `core/frontend/durable/provider_chunk.go` `recoverChunk`, `chunkAuthorityWait`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestLayoutProviderRefusesEmptyOwnEpochAndRemountedOldRoot`, `TestFinalLayoutStartRefusalTable` (`core/frontend/durable/provider_layout_test.go`, `provider_layout_start_class_test.go`) | — | ACTIVE | | `INV-WS-ONE-PROCESS-PER-HOST-001` | One host runs at most one live blockvolume per volume: each takes the volume's exclusive host lock before its store opens and holds it until the store closes; a second is refused before it opens anything, whatever its `--durable-root`. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockRefusesNonDirectoryLockPath`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestHostVolumeLockCreatesParent0755AndLocks0700`, `TestHostVolumeLockKeepsExistingDirectoryModes` (`core/frontend/durable/volume_lock_parent_mode_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE | | `INV-CHUNK-LEASE-REQUIRED-001` | Blockvolume refuses walstore-chunk startup without --workspace-lease before any host or store is opened. The refusal names concurrent acknowledging writers and acknowledged-write loss after a forced move; plain walstore startup is unchanged. | M4 startup → Refused | `cmd/blockvolume/main.go` `parseFlags` | `TestChunkVolumeRequiresWorkspaceLeaseBeforeStart` | — | ACTIVE | -| `INV-WS-CONDITIONAL-HEAD-001` | Catalog startup requires a wrong-generation conditional update of a disposable HEAD to be definitely refused and leave its bytes and generation unchanged. Unknown outcomes or cleanup failures refuse admission. No volume HEAD is used for the probe. | M4 startup → Refused | `core/frontend/chunkstore/swfs_catalog.go` `DialBCatalog`; `startup_head_probe.go` `checkConditionalHead` | `TestCatalogStartupRequiresWrongGenerationHeadRefusal` | — | ACTIVE | +| `INV-WS-CONDITIONAL-HEAD-001` | Catalog startup requires a wrong-generation conditional update of a disposable HEAD to be definitely refused and leave its bytes and generation unchanged. Unknown probe outcomes refuse admission; cleanup failures only warn with the leftover path. No volume HEAD is used. | M4 startup → Refused | `core/frontend/chunkstore/swfs_catalog.go` `DialBCatalog`; `startup_head_probe.go` `checkConditionalHead` | `TestCatalogStartupRequiresWrongGenerationHeadRefusal` | — | ACTIVE | | `INV-WS-SINGLE-FILER-001` | Startup requires all configured masters to answer and agree on a leader; only that leader listing exactly the target filer and confirming leadership afterward admits. Followers' lists do not decide. Unknown views retry within 60 s. This census does not fence later filer registration. | M4 (startup) → Refused | `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `cmd/blockvolume/chunk_remote.go` `newChunkWiring`; `cmd/sw-block/chunk.go` `refuseUnlessSingleFiler` | `TestSingleFilerCensusUsesTheAgreedLeader`; `TestCheckSingleFilerRefusesAnotherOrSeveralFilers`, `TestCheckSingleFilerFailsClosed`, `TestCheckSingleFilerNeedsEveryMasterToAnswer`, `TestIsTargetComparesScopedAddresses`, `TestCheckSingleFilerPasses` (`core/frontend/chunkstore/single_filer_test.go`), `TestChunkWiringRefusesAMultiFilerGroup` (`cmd/blockvolume/single_filer_test.go`), `TestOpsChunk_WritingCommandsRunTheSingleFilerCheck` (`cmd/sw-block/chunk_start_check_test.go`), `TestOpsChunk_VerifyRunsTheSingleFilerCheck` (`cmd/sw-block/chunk_verify_test.go`) | — | ACTIVE | | `INV-WS-LEASE-REGRANT-001` | Re-grant after expiry keeps the same holder and epoch, with no pending move or revocation, a certain store, and one durable write after the horizon/deadline plus skew barrier. Restart begins a new session and voids the old; ordinary reopen keeps HEAD identity (epoch, holder, claim) unchanged. | M2 Expired → Granted; M9 Start | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/frontend/chunkstore/layout/start.go` `Start` | `TestWorkspaceLeaseExpiredSameHolderRegrantIsDurable`, `TestWorkspaceLeaseRegrantWaitsForFullSkew`, `TestWorkspaceLeaseRegrantDefeatsAlreadyPassedForcedPreflight`, `TestWorkspaceLeaseForcedIssueDefeatsOldHolderRegrant`, `TestWorkspaceLeaseRegrantWaitsForDurabilityAndLatchesFailure` (`core/authority/workspace_regrant_test.go`); `TestWorkspaceLeaseRegrantPreservesLocalLogThroughFirstCut` (`core/authority/workspace_regrant_storage_test.go`); `TestStart_OwnEpochFreshRootRefusedBeforeClaim`, `TestStart_OwnEpochSameRootContinues` (`core/frontend/chunkstore/layout/start_test.go`); `TestClaim_WritesItsClaimID`, `TestRunClaim_VoidsTheOldSession` (`core/frontend/chunkstore/layout/claim_test.go`); `TestLocalReopenClaimsBeforeServing` (`core/frontend/durable/provider_reopen_belt_test.go`) | `WorkspaceRegrant` `NoDualServingInc`, `RegrantNoLoss`, `DiskCoversMemory`; `INV-SNAPK-START-ROOT-001` | ACTIVE | | `INV-WS-LEASE-001` | A host admits frontend I/O and cuts only under an unexpired lease for its exact `{volume, replica, epoch}`; a fenced guard never reopens, even on a late renewal reply. | M4 lease guard: Valid → Fenced | `core/host/volume/workspace_lease.go` `permits`, `Refresh` | `TestWorkspaceLeaseExpiryFencesWithoutTimerAndCannotReopen`, `TestWorkspaceDelayedRenewalCannotUndoExpiry` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostRequiresLeaseBeforeFrontendAndCut` (`core/host/volume/workspace_runtime_test.go`); `TestWorkspacePausedGranteeRefusedAtAttach` (`core/host/master/workspace_paused_grantee_test.go`) | `WorkspaceTakeover` `NoDualServing` | ACTIVE | diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index f09a38cdd7..250904ef18 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -1019,12 +1019,16 @@ Blockmaster and blockvolume catalog startup first checks the single-filer configuration, then probes conditional HEAD updates in a random `.startup-head-probe-` directory under the configured chunk path. A fresh inline HEAD at generation 1 must reject an update expecting generation 2 and -remain unchanged. Success, an ambiguous answer, a changed probe or a cleanup -failure refuses startup. No volume HEAD or chunk payload is touched. +remain unchanged. An accepted wrong-generation update, an ambiguous answer or a +changed probe refuses startup. A cleanup failure logs the leftover path and does +not refuse a start whose probe succeeded. No volume HEAD or chunk payload is touched. The exchange is bounded by 10 seconds plus up to 5 seconds for non-recursive cleanup, in addition to the single-filer census. The service account needs create/read/update/delete permission under the chunk path. A failed or lost create answer may leave the named probe directory for inspection; the error -names it. This is an admission check, not an ongoing fence against later filer +names it. A daemon killed before cleanup can also leave a +`.startup-head-probe-` directory; these disposable probe directories are safe +to delete, and the product does not sweep them automatically. This is an +admission check, not an ongoing fence against later filer configuration changes.