mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
Run abandoned probe cleanup after catalog admission
This commit is contained in:
1 parent
7c4d6043c4
commit
ed35f1377a
6 files changed
+71
-12
No files matched your search
@@ -107,9 +107,6 @@ func (c *BCatalog) cleanStartupProbes(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (c *BCatalog) checkConditionalHead(ctx context.Context) error {
|
||||
if err := c.cleanStartupProbes(ctx); err != nil {
|
||||
log.Printf("chunkstore: WARNING conditional HEAD probe leftover sweep failed: base=%q error=%v", c.base, err)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, startupProbeTimeout)
|
||||
defer cancel()
|
||||
id, err := layout.NewVolumeID()
|
||||
@@ -139,8 +136,9 @@ func (c *BCatalog) checkConditionalHead(ctx context.Context) error {
|
||||
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
|
||||
// random directory: expected generation 2 must be refused, not acknowledged.
|
||||
// The exclusive create installed generation 1: expected generation 2 must
|
||||
// be refused, not acknowledged. A concurrent sweep may instead make this
|
||||
// probe fail closed; it can never establish conditional support by deletion.
|
||||
err = st.UpdateHead(ctx, 2, h, layout.CauseCreate)
|
||||
if !errors.Is(wire.updateError, ErrPrecondition) {
|
||||
return fmt.Errorf("%w: wrong-generation update of %s was not definitely refused: %v", ErrConditionalHead, root, err)
|
||||
|
||||
@@ -216,6 +216,10 @@ func TestConditionalHeadNextStartCleansCrashLeftovers(t *testing.T) {
|
||||
if err := c.checkConditionalHead(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// DialBCatalog runs this sweep in the background after admission.
|
||||
if err := c.cleanStartupProbes(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, name := range []string{abandoned, empty} {
|
||||
if _, err := f.LookupEntry(ctx, "/blocks", name); !errors.Is(err, ErrNotFound) {
|
||||
t.Fatalf("crash probe directory remains %s: %v", name, err)
|
||||
@@ -271,3 +275,35 @@ func TestConditionalHeadSweepWaitsAndLeavesNewProbes(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestCatalogStartupDoesNotWaitForUndeletableProbe(t *testing.T) {
|
||||
srv := grpc.NewServer()
|
||||
lis, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f := &conditionalProbeServer{store: newFakeFiler(), mode: "cleanup-head-error"}
|
||||
leftover := startupProbePrefix + strings.Repeat("5", 32)
|
||||
if err := f.store.CreateEntry(context.Background(), "/blocks", &filerpb.Entry{Name: leftover, IsDirectory: true}, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
filerpb.RegisterSeaweedFilerServer(srv, f)
|
||||
go func() { _ = srv.Serve(lis) }()
|
||||
t.Cleanup(srv.Stop)
|
||||
_, port, _ := net.SplitHostPort(lis.Addr().String())
|
||||
f.masters = []string{startMaster(t, &nodesMaster{filers: []string{"127.0.0.1:8888." + port}})}
|
||||
// Readiness must fit this budget even though the leftover sweep waits 15 s
|
||||
// and deletion of every probe HEAD fails. No wider startup timeout is needed.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
cat, client, err := DialBCatalog(ctx, SWFSConfig{FilerGRPC: lis.Addr().String(), AssignPath: "/blocks"})
|
||||
if client != nil {
|
||||
defer client.Close()
|
||||
}
|
||||
if err != nil || cat == nil {
|
||||
t.Fatalf("leftover delayed catalog readiness: %v", err)
|
||||
}
|
||||
if _, err := f.store.LookupEntry(ctx, "/blocks", leftover); err != nil {
|
||||
t.Fatalf("undeletable leftover disappeared: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,9 @@ type SWFS struct {
|
||||
|
||||
mu sync.Mutex
|
||||
vidCache map[string][]string // volume id -> volume server urls
|
||||
|
||||
probeCleanupCancel context.CancelFunc
|
||||
probeCleanupDone <-chan struct{}
|
||||
}
|
||||
|
||||
// filerNotFoundText is the text of seaweed-mono's filer_pb.ErrNotFound
|
||||
@@ -92,6 +95,10 @@ func newBlobHTTPClient(timeout time.Duration) *http.Client {
|
||||
// Close releases the gRPC connection and the blob client's idle
|
||||
// connections (the client owns its transport).
|
||||
func (c *SWFS) Close() error {
|
||||
if c.probeCleanupCancel != nil {
|
||||
c.probeCleanupCancel()
|
||||
<-c.probeCleanupDone
|
||||
}
|
||||
if c.http != nil {
|
||||
c.http.CloseIdleConnections()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package chunkstore
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
)
|
||||
|
||||
// DialBCatalog gives master creation and blockvolume attachment the same
|
||||
// single-filer check, storage rule, and catalog path.
|
||||
@@ -22,5 +25,18 @@ func DialBCatalog(ctx context.Context, cfg SWFSConfig) (*BCatalog, *SWFS, error)
|
||||
_ = client.Close()
|
||||
return nil, nil, err
|
||||
}
|
||||
// Admission does not wait for old metadata to become removable. Cleanup is
|
||||
// owned by this client, independent of the caller's startup deadline, and
|
||||
// canceled and joined when the client closes.
|
||||
cleanup, cancel := context.WithCancel(context.WithoutCancel(ctx))
|
||||
client.probeCleanupCancel = cancel
|
||||
done := make(chan struct{})
|
||||
client.probeCleanupDone = done
|
||||
go func() {
|
||||
defer close(done)
|
||||
if err := cat.cleanStartupProbes(cleanup); err != nil && cleanup.Err() == nil {
|
||||
log.Printf("chunkstore: WARNING conditional HEAD probe leftover sweep failed: base=%q error=%v", cat.base, err)
|
||||
}
|
||||
}()
|
||||
return cat, client, nil
|
||||
}
|
||||
@@ -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 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`, `TestConditionalHeadNextStartCleansCrashLeftovers`, `TestConditionalHeadSweepWaitsAndLeavesNewProbes`, `TestLayoutIdentityWriterAndReaders` | — | 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`, `TestConditionalHeadNextStartCleansCrashLeftovers`, `TestConditionalHeadSweepWaitsAndLeavesNewProbes`, `TestCatalogStartupDoesNotWaitForUndeletableProbe`, `TestLayoutIdentityWriterAndReaders` | — | 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 |
|
||||
|
||||
@@ -1035,13 +1035,15 @@ create/read/list/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. A daemon killed before cleanup can also leave a
|
||||
`.startup-head-probe-<id>` directory; these disposable probe directories are safe
|
||||
to delete. At the next catalog start, the product lists exact reserved probe
|
||||
names before creating its own probe. If any exist, it waits the existing
|
||||
10-second exchange plus 5-second cleanup window before removing only the
|
||||
observed HEAD entries and empty directories, non-recursively. Newly listed
|
||||
to delete. After the next catalog start proves conditional support and admits
|
||||
its caller, a background task lists exact reserved probe names. If any exist,
|
||||
it waits the existing 10-second exchange plus 5-second cleanup window before
|
||||
removing only the observed HEAD entries and empty directories, non-recursively.
|
||||
The wait, listing and removals do not delay catalog readiness. Newly listed
|
||||
names with anything other than 32 lower-case nonzero hex digits after the prefix
|
||||
are not probes; real volume directories end in a separate `-<8 hex>` suffix.
|
||||
Each sweep RPC has a 5-second bound; a failed sweep logs a warning and a later
|
||||
start retries. The extra wait occurs only when leftovers were observed. This is an
|
||||
start retries. Closing the filer client cancels and joins this background task.
|
||||
An undeletable leftover cannot add a sweep delay to later starts. This is an
|
||||
admission check, not an ongoing fence against later filer
|
||||
configuration changes.
|
||||
Reference in new issue
Block a user