mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
The startup inactivity window renewed only on replay, scan, map and attach work. A new store's prezero and the WAL fence wrote and synced whole regions with no report, so on a slow disk the window could end inside one silent step; and the chunk layer's wait for master authority, a wait the master bounds, ran out the same window. - storage: phases RecoveryCreate and RecoveryFence; syncedSlices runs a sized step 4 MiB at a time and reports a slice only after its sync; prezeroNewStore uses it, and recovery reports the fence's synced bytes. - durable: create passes RecoveryProgress; AuthorityWait tells the host when the authority wait starts and ends; Chunk.AuthorityGap names the projection fields that withhold authority. - host: recovery_timeout becomes recovery_stalled; waits are counted, the window pauses while any runs and restarts when the last ends, a stall latched before stays latched; /status RecoveryWait=awaiting_authority. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.7 KiB
Go
72 lines
2.7 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
|
|
"github.com/seaweedfs/seaweed-block/core/host/volume"
|
|
"github.com/seaweedfs/seaweed-block/core/storage"
|
|
)
|
|
|
|
// durableStartup is the part of the durable provider the startup open
|
|
// and replay step uses.
|
|
type durableStartup interface {
|
|
EnsureStorage(volumeID string) (storage.LogicalStorage, error)
|
|
RecoverVolume(ctx context.Context, volumeID string) (durable.RecoveryReport, error)
|
|
}
|
|
|
|
// localRecoveryHost is the part of the volume host the startup step
|
|
// reports to.
|
|
type localRecoveryHost interface {
|
|
BlockLocalReadiness(reason string)
|
|
ClearLocalReadinessBlock()
|
|
ReportLocalRecoveryFailure(err error) string
|
|
}
|
|
|
|
type durableStartupOutcome int
|
|
|
|
const (
|
|
durableStartupReady durableStartupOutcome = iota // storage open and replayed
|
|
durableStartupFaulted // fail closed, keep serving status and heartbeats
|
|
durableStartupFatal // unclassified open failure: exit as before
|
|
)
|
|
|
|
// openAndRecoverDurable opens the volume's durable storage and replays it
|
|
// at startup (#133). On a classifiable failure in either step (open or
|
|
// replay), it blocks local readiness, records the typed reason
|
|
// (wal_corrupt / io_error) through ReportLocalRecoveryFailure, and returns
|
|
// durableStartupFaulted: the process stays up fail-closed, with frontend
|
|
// I/O refused, and a primary assignment reports the reason at once. A
|
|
// replay failure that cannot be classified is faulted too, as before, and
|
|
// is covered by the recovery_stalled fallback. An open failure that
|
|
// cannot be classified returns durableStartupFatal, keeping the earlier
|
|
// exit.
|
|
func openAndRecoverDurable(dp durableStartup, h localRecoveryHost, volumeID string, _ time.Duration) (durableStartupOutcome, string, error) {
|
|
if _, err := dp.EnsureStorage(volumeID); err != nil {
|
|
if volume.LocalRecoveryHealthReason(err) == "" {
|
|
return durableStartupFatal, "", err
|
|
}
|
|
evidence := "durable storage open failed: " + err.Error()
|
|
h.BlockLocalReadiness(evidence)
|
|
h.ReportLocalRecoveryFailure(err)
|
|
return durableStartupFaulted, evidence, err
|
|
}
|
|
// The host owns the shared inactivity clock. Volume-sized local replay
|
|
// must not consume an attach operation's fixed deadline.
|
|
ctx := context.Background()
|
|
if progress, ok := h.(interface {
|
|
ReportRecoveryProgress(storage.RecoveryPhase, uint64)
|
|
}); ok {
|
|
ctx = storage.WithRecoveryProgress(ctx, progress.ReportRecoveryProgress)
|
|
}
|
|
report, err := dp.RecoverVolume(ctx, volumeID)
|
|
if err != nil {
|
|
h.BlockLocalReadiness(report.Evidence)
|
|
h.ReportLocalRecoveryFailure(err)
|
|
return durableStartupFaulted, report.Evidence, err
|
|
}
|
|
h.ClearLocalReadinessBlock()
|
|
return durableStartupReady, report.Evidence, nil
|
|
}
|