diff --git a/seaweed-block/cmd/sw-block/chunk.go b/seaweed-block/cmd/sw-block/chunk.go index 8c1802e257..3837e48c24 100644 --- a/seaweed-block/cmd/sw-block/chunk.go +++ b/seaweed-block/cmd/sw-block/chunk.go @@ -48,10 +48,10 @@ var dialChunkFiler = func(addr string) (chunkstore.Filer, func() error, error) { // metadata: block metadata goes through exactly one filer, the // same rule blockvolume enforces at start. Tests replace it. var checkSingleFiler = func(ctx context.Context, f chunkstore.Filer) error { - if s, ok := f.(*chunkstore.SWFS); ok { + if s, ok := f.(*chunkstore.SWFS); ok && s != nil { return s.CheckSingleFiler(ctx) } - return nil + return fmt.Errorf("%w: single-filer census requires a live SWFS client, got %T", chunkstore.ErrNotSingleFiler, f) } // refuseUnlessSingleFiler runs the start check within the command's own diff --git a/seaweed-block/cmd/sw-block/chunk_b_test.go b/seaweed-block/cmd/sw-block/chunk_b_test.go index 18a929fe47..e09836119b 100644 --- a/seaweed-block/cmd/sw-block/chunk_b_test.go +++ b/seaweed-block/cmd/sw-block/chunk_b_test.go @@ -57,6 +57,7 @@ var testIDs sync.Map // names against testIDs. func useMemChunkStore(t *testing.T, store *memChunkStore) { t.Helper() + assumeSingleFilerFixture(t) prev, prevResolve, prevRestore := dialChunkFiler, resolveVolumeID, restoreCreateRPC dialChunkFiler = func(string) (chunkstore.Filer, func() error, error) { return store, func() error { return nil }, nil } resolveVolumeID = testResolve @@ -429,3 +430,12 @@ func TestOpsChunkVolumeDeleteRequiresTheMastersLeaseProof(t *testing.T) { t.Fatalf("HEAD changed despite refused proof: %+v %v %v", h, found, err) } } + +// Catalog fixtures model one in-memory namespace; inject that census result +// explicitly. Production clients must perform the live SWFS group census. +func assumeSingleFilerFixture(t *testing.T) { + t.Helper() + prev := checkSingleFiler + checkSingleFiler = func(context.Context, chunkstore.Filer) error { return nil } + t.Cleanup(func() { checkSingleFiler = prev }) +} diff --git a/seaweed-block/cmd/sw-block/chunk_verify_test.go b/seaweed-block/cmd/sw-block/chunk_verify_test.go index 048dee6071..551563eec8 100644 --- a/seaweed-block/cmd/sw-block/chunk_verify_test.go +++ b/seaweed-block/cmd/sw-block/chunk_verify_test.go @@ -19,6 +19,7 @@ import ( // one root naming chunks 0 and 1) on an in-memory filer and blob store; it // returns the store and chunk 1's pool path. func verifyCLIFixture(t *testing.T) (*manifestFixtureFiler, string) { + assumeSingleFilerFixture(t) t.Helper() ctx := context.Background() mem := newManifestFixtureFiler(chunkstore.NewMemFiler()) diff --git a/seaweed-block/cmd/sw-block/volume_backup_test.go b/seaweed-block/cmd/sw-block/volume_backup_test.go index e34a803a6a..0a3ccad9e6 100644 --- a/seaweed-block/cmd/sw-block/volume_backup_test.go +++ b/seaweed-block/cmd/sw-block/volume_backup_test.go @@ -318,6 +318,7 @@ func serveRestoreMaster(t *testing.T) (*restoreMaster, string) { t.Fatal(err) } prev := dialChunkFiler + assumeSingleFilerFixture(t) dialChunkFiler = func(string) (chunkstore.Filer, func() error, error) { return store, func() error { return nil }, nil } t.Cleanup(func() { dialChunkFiler = prev }) m := &restoreMaster{vols: map[string]*restoreRec{}, ids: map[string]layout.VolumeID{}, cat: cat, src: cliVolume(t, store, "vol-a", "s1"), diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 80e1ed18d8..44f9599d34 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -832,6 +832,7 @@ Notes: | `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-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-CLI-SINGLE-FILER-CLIENT-001` | Chunk metadata commands refuse missing, typed-nil and non-SWFS clients before catalog access; only a live SWFS client can run the census. | M4 startup client admission | `cmd/sw-block/chunk.go` `checkSingleFiler`, `refuseUnlessSingleFiler` | `TestSingleFilerCheckRefusesUnsupportedClients`, `TestOpsChunkWritingRefusesUnsupportedFilerBeforeCatalogAccess` | — (client capability guard) | 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 | | `INV-WS-REVOKE-ACK-RECORDED-001` | A matching recorded revocation stop is answered before lease checks without writing or extending the lease. An expired lease still refuses a first ACK, and a changed replica, epoch, holder or stopped position never replays another ACK. | M2 revocation ACK replay, no state change | `core/authority/workspace.go` `AckWorkspaceRevocation` | `TestRecordedRevocationAckRetryAfterDeadline`, `TestRecordedAckLostReplyAfterMasterDeadlineDrainsWithoutRetryExit`, `TestUnrecordedRevocationAckStillRefusesAfterDeadline` | WorkspaceTakeover CleanNoLoss; replay stutters | ACTIVE |