mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
durable: the authority pause follows every transition, not only the first grant
A grant whose attach failed and whose authority was then lost returned to the wait without a new pause, so the master's resumed wait could read as a stall. The pause now starts whenever authority is missing and ends at each grant, before the local attach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb542b3c21
commit
49ca6baf55
3 files changed
+68
-12
No files matched your search
@@ -101,3 +101,57 @@ func TestAuthorityWaitEndsAtTheGrantBeforeTheAttach(t *testing.T) {
|
||||
t.Fatalf("authority wait reports after the attach: %v, want exactly one start and one end", seen)
|
||||
}
|
||||
}
|
||||
|
||||
// Authority granted, its attach failed, then authority lost before the
|
||||
// retry: the retry returns to the wait, which pauses the stall window
|
||||
// again; the next grant ends that pause and the volume attaches.
|
||||
func TestAuthorityLostAfterAGrantPausesAgain(t *testing.T) {
|
||||
var mu sync.Mutex
|
||||
var seen []bool
|
||||
snapshot := func() []bool {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return append([]bool(nil), seen...)
|
||||
}
|
||||
g := newGated(storage.NewMemChunkRemote())
|
||||
g.failGetHead = 1 // the first granted attach fails; its retry waits a second
|
||||
view := newStubView(frontend.Projection{VolumeID: "v1", ReplicaID: "r1"})
|
||||
p := chunkProvider(t, t.TempDir(), g, view, 0, func(cfg *durable.ProviderConfig) {
|
||||
cfg.AuthorityWait = func(waiting bool) {
|
||||
mu.Lock()
|
||||
seen = append(seen, waiting)
|
||||
mu.Unlock()
|
||||
}
|
||||
})
|
||||
if _, err := p.EnsureStorage("v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := p.RecoverVolume(context.Background(), "v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
granted := healthyProj(frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 4, EndpointVersion: 2})
|
||||
view.set(granted)
|
||||
waitFor(t, 20*time.Second, "the grant ends the pause", func() bool {
|
||||
got := snapshot()
|
||||
return len(got) == 2 && got[0] && !got[1]
|
||||
})
|
||||
view.set(frontend.Projection{VolumeID: "v1", ReplicaID: "r1"}) // lost before the retry
|
||||
waitFor(t, 20*time.Second, "the resumed wait pauses again", func() bool {
|
||||
got := snapshot()
|
||||
return len(got) >= 3 && got[2]
|
||||
})
|
||||
view.set(granted)
|
||||
waitFor(t, 20*time.Second, "the attach after the second grant", func() bool {
|
||||
st := p.DurableStatuses()
|
||||
return len(st) == 1 && st[0].Chunk != nil && st[0].Chunk.Attached
|
||||
})
|
||||
got := snapshot()
|
||||
if len(got)%2 != 0 {
|
||||
t.Fatalf("pause reports %v: every pause must end", got)
|
||||
}
|
||||
for i, w := range got {
|
||||
if w != (i%2 == 0) {
|
||||
t.Fatalf("pause reports %v: starts and ends must alternate", got)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,19 +185,20 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen
|
||||
log.Printf("durable: chunk layer for volume=%s waits for master authority (%s): projection lacks %s",
|
||||
volumeID, bound, chunkAuthorityGap(p.view.Projection(), volumeID))
|
||||
// The wait's bound is the master's: the startup stall window pauses
|
||||
// while authority is missing and restarts at the grant, before any local
|
||||
// attach work, so a stuck attach is still a stall.
|
||||
endPause := func() {}
|
||||
// while authority is missing and restarts at each grant, before any local
|
||||
// attach work, so a stuck attach is still a stall; authority lost again
|
||||
// before an attach pauses it again.
|
||||
setPaused := func(bool) {}
|
||||
if aw := p.cfg.AuthorityWait; aw != nil {
|
||||
aw(true)
|
||||
paused := true
|
||||
endPause = func() {
|
||||
if paused {
|
||||
paused = false
|
||||
aw(false)
|
||||
paused := false
|
||||
setPaused = func(want bool) {
|
||||
if want != paused {
|
||||
paused = want
|
||||
aw(want)
|
||||
}
|
||||
}
|
||||
defer endPause()
|
||||
setPaused(true)
|
||||
defer setPaused(false)
|
||||
}
|
||||
ended := "superseded by a later recovery"
|
||||
defer func() {
|
||||
@@ -264,6 +265,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen
|
||||
}
|
||||
proj := p.view.Projection()
|
||||
if !chunkAuthority(proj, volumeID) {
|
||||
setPaused(true) // missing (again): the master's wait
|
||||
// Authority first: a grant that arrives on the same tick as the
|
||||
// bound attaches instead of giving up.
|
||||
if gaveUp() {
|
||||
@@ -278,7 +280,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen
|
||||
expired, ended = true, "assignment allowance ended before attach retry"
|
||||
return
|
||||
}
|
||||
endPause() // granted: the attach below is local work again
|
||||
setPaused(false) // granted: the attach below is local work again
|
||||
if attempts++; attempts == 1 {
|
||||
log.Printf("durable: chunk layer for volume=%s: master authority after %s (replica=%q epoch=%d endpoint=%d); first attach attempt",
|
||||
volumeID, time.Since(start), proj.ReplicaID, proj.Epoch, proj.EndpointVersion)
|
||||
|
||||
@@ -612,7 +612,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w
|
||||
| `INV-WAL-SYNCED-RECOVERED-001` | After a crash without media corruption, `Recover` returns every write that a `Sync` acknowledged. | M1 Recovering → Serving | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover` | `TestNativeReplacementTornWrapKeepsAcknowledgedSuffix` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE |
|
||||
| `INV-RECOVERY-PROGRESS-WINDOW-001` | Startup reports recovery_stalled only after a window without a new fixed-order phase/count frontier; repeated preparation cannot renew it. Progress never grants readiness or ownership. | M1 Recovering | `core/host/volume/recovery_watchdog.go`; `cmd/blockvolume/durable_startup.go`; `core/storage/recovery_progress.go` | `TestDurableStartup_LocalRecoveryWorkIsOutsideFixedDeadline` (`cmd/blockvolume/durable_startup_budget_test.go`); `TestRecoveryProgress_CountingEntriesOutliveTheTotalWindow`, `TestRecoveryProgress_RepeatedAttachPreparationDoesNotRenew` (`core/host/volume/recovery_progress_test.go`); attach: `TestAttachReportsItsVolumeSizedLocalWork`, `TestAttachReportsTheCreatedThisStartScan`, `TestAttachProgressFlushesSlowWorkAboutEverySecond` (`core/storage/chunk_attach_progress_test.go`), `TestAttachProgressCountsEachAttemptFromZero`, `TestAttachRemoteCallsCarryTheirOwnBound`, `TestAttachManifestReadCarriesThePerFetchRule` (`core/frontend/durable/attach_progress_test.go`), `TestAttachManifestReadBoundsEachFetch` (`core/frontend/chunkstore/layout_attach_fetch_test.go`) | — (joint recovery+attach Linux qualification: 7495 PASS, 0 FAIL, race x5 including the attach tests); C.L | ACTIVE |
|
||||
| `INV-RECOVERY-SIZED-STEP-SLICES-001` | A sized startup step (a new store's prezero, the WAL fence) reports its bytes as recovery progress only after their sync, prezero one 4 MiB slice at a time. | M1 Recovering | `core/storage/recovery_progress.go` `syncedSlices`; `core/storage/data_sync.go` `prezeroNewStore`; `core/storage/walstore_v3.go` `fenceV3` | `TestSyncedSlicesCountOnlySyncedSlices`, `TestPrezeroReportsEachSyncedSlice`, `TestRecoveryReportsTheSyncedFence`, `TestRecoveryFenceHeldSyncReportsAfterRelease`, `TestPrezeroReportsAfterEachSyncAndStopsAtAFailedOne` (`core/storage/recovery_create_progress_test.go`); `TestRecoveryStalled_CreateSlicesRenewTheWindow` (`core/host/volume/recovery_authority_wait_test.go`) | — | ACTIVE |
|
||||
| `INV-RECOVERY-AUTHORITY-WAIT-PAUSE-001` | The recovery_stalled window pauses while a recovered volume awaits master authority and restarts at the grant, before local attach work; silence that filled the window before the wait is latched at its start. The master bounds the wait. | M1 Recovering | `core/host/volume/recovery_watchdog.go` `ReportAuthorityWait`; `core/frontend/durable/provider_chunk.go` `chunkAuthorityWait` | `TestRecoveryStalled_FullAuthorityWaitDoesNotStall`, `TestRecoveryStalled_SilentStepBeyondTheWindowIsCaught`, `TestRecoveryStalled_SilenceBeforeTheWaitIsLatchedAtItsStart`, `TestRecoveryStalled_HeldAttachAfterTheGrantStalls` (`core/host/volume/recovery_authority_wait_test.go`); `TestAuthorityWaitIsReportedAndShowsItsGap`, `TestAuthorityWaitEndsAtTheGrantBeforeTheAttach` (`core/frontend/durable/authority_wait_hook_test.go`) | — | ACTIVE |
|
||||
| `INV-RECOVERY-AUTHORITY-WAIT-PAUSE-001` | The recovery_stalled window pauses while a recovered volume awaits master authority and restarts at the grant, before local attach work; silence that filled the window before the wait is latched at its start. The master bounds the wait. | M1 Recovering | `core/host/volume/recovery_watchdog.go` `ReportAuthorityWait`; `core/frontend/durable/provider_chunk.go` `chunkAuthorityWait` | `TestRecoveryStalled_FullAuthorityWaitDoesNotStall`, `TestRecoveryStalled_SilentStepBeyondTheWindowIsCaught`, `TestRecoveryStalled_SilenceBeforeTheWaitIsLatchedAtItsStart`, `TestRecoveryStalled_HeldAttachAfterTheGrantStalls` (`core/host/volume/recovery_authority_wait_test.go`); `TestAuthorityWaitIsReportedAndShowsItsGap`, `TestAuthorityWaitEndsAtTheGrantBeforeTheAttach`, `TestAuthorityLostAfterAGrantPausesAgain` (`core/frontend/durable/authority_wait_hook_test.go`) | — | ACTIVE |
|
||||
| `INV-OPEN-REMOVED-ENGINE-REFUSED-001` | A volume whose header carries a removed experimental engine's magic (smartwal `SWAW`; parallel-walstore `SWPW` at offset 0 or 4096) is refused typed (copy the data to a walstore volume with v1.0.x first) under every selector, read-only and never modified. | M1 [*] → OpenRefused | `core/frontend/durable/provider.go` `verifyImplOnDisk` | `TestDurableProvider_RefusesRemovedEngineVolumes` (byte-identical file after each refusal; `core/frontend/durable/provider_auto_impl_test.go`); `TestWALStoreChunk_SelectorRules` (`core/frontend/durable/provider_chunk_test.go`) | — | ACTIVE |
|
||||
| `INV-OPEN-REMOVED-ENGINE-NAME-REFUSED-001` | A selector naming a removed experimental engine (`smartwal`, `parallel-walstore`) is refused typed, with the same advice, by blockvolume, the provider and the Kubernetes launcher before any volume is touched. | M1 [*] → OpenRefused | `core/frontend/durable/provider.go` `RemovedEngineName`, `NewDurableProvider`; `cmd/blockvolume/main.go` `parseFlags`; `core/launcher/k8s_renderer.go` | `TestDurableProvider_RefusesRemovedEngineNames` (`core/frontend/durable/provider_auto_impl_test.go`); `TestBlockvolumeRefusesRemovedEngineNames` (`cmd/blockvolume/durable_impl_default_test.go`); `TestK8sRendererRefusesRemovedEngines` (`core/launcher/k8s_renderer_test.go`) | — | ACTIVE |
|
||||
| `INV-WAL-OPGATE-001` | A durable backend refuses `Read`, `Write` and `Sync` until `RecoverVolume` succeeds; a failed recovery leaves it refused. | M1 Opened → Serving; Recovering → RecoveryFailed | `core/frontend/durable/storage_adapter.go` `readyCheck`; `core/frontend/durable/provider.go` `RecoverVolume` | `TestT3b_DurableProvider_Open_StartsNotOperational` (`core/frontend/durable/provider_test.go`); `TestT3b_Recovery_CleanRecover_FlipsOperational` (`core/frontend/durable/recovery_test.go`); `TestWALStoreChunk_MoveBackOntoAnOldRootIsRefused` (`core/frontend/durable/provider_chunk_moveback_test.go`) | — | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user