mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
fix(nvme): retry reads while the backend is not ready
This commit is contained in:
1 parent
93529c04fd
commit
bdf45a43f8
4 files changed
+11
-3
No files matched your search
@@ -9,7 +9,8 @@ import "errors"
|
||||
var ErrStalePrimary = errors.New("frontend: stale primary lineage")
|
||||
|
||||
// ErrNotReady is returned by Provider.Open when the projection
|
||||
// never reports healthy before the context deadline.
|
||||
// never reports healthy before the context deadline, and by a Backend
|
||||
// while local recovery or chunk attachment is not yet operational.
|
||||
var ErrNotReady = errors.New("frontend: volume not ready")
|
||||
|
||||
// ErrBackendClosed is returned by Backend.Read / Backend.Write
|
||||
|
||||
@@ -76,7 +76,7 @@ type IOResult struct {
|
||||
SC uint8
|
||||
Data []byte // read payload (nil for writes / errors)
|
||||
Reason string
|
||||
retryable bool // only transient backend pressure clears wire DNR
|
||||
retryable bool // transient pressure or readiness refusal clears wire DNR
|
||||
}
|
||||
|
||||
func (r IOResult) completionStatus() uint16 { return MakeStatusField(r.SCT, r.SC, !r.retryable) }
|
||||
@@ -296,7 +296,8 @@ func (h *IOHandler) write(ctx context.Context, cmd IOCommand) IOResult {
|
||||
|
||||
// mapBackendError translates frontend errors into NVMe CQE
|
||||
// status tuples. ErrStalePrimary → ANA Transition;
|
||||
// ErrBackendClosed → ANA Inaccessible; anything else → Internal
|
||||
// ErrBackendClosed → ANA Inaccessible; ErrNotReady → retryable Namespace
|
||||
// Not Ready; anything else → Internal
|
||||
// Error (fail-closed; real-backend-specific mapping lands with
|
||||
// T3).
|
||||
func mapBackendError(err error, op string) IOResult {
|
||||
@@ -317,6 +318,9 @@ func mapBackendError(err error, op string) IOResult {
|
||||
Reason: "backend closed on " + op,
|
||||
}
|
||||
}
|
||||
if errors.Is(err, frontend.ErrNotReady) {
|
||||
return IOResult{SCT: SCTGeneric, SC: SCNamespaceNotReady, Reason: "backend not ready on " + op + ": " + err.Error(), retryable: true}
|
||||
}
|
||||
return IOResult{
|
||||
SCT: SCTGeneric,
|
||||
SC: SCInternalError,
|
||||
|
||||
@@ -25,6 +25,8 @@ func TestSessionReadNotReadyIsRetryable(t *testing.T) {
|
||||
dnr bool
|
||||
}{
|
||||
{"attach-pending", fmt.Errorf("awaiting HEAD attach: %w", frontend.ErrNotReady), SCTGeneric, SCNamespaceNotReady, false},
|
||||
{"not-ready-closed", errors.Join(frontend.ErrNotReady, frontend.ErrBackendClosed), SCTPathRelated, SCPathAsymAccessInaccessible, true},
|
||||
{"not-ready-stale", errors.Join(frontend.ErrNotReady, frontend.ErrStalePrimary), SCTPathRelated, SCPathAsymAccessTransition, true},
|
||||
{"physical-fault", errors.New("physical read failure"), SCTGeneric, SCInternalError, true},
|
||||
{"closed", frontend.ErrBackendClosed, SCTPathRelated, SCPathAsymAccessInaccessible, true},
|
||||
{"stale", frontend.ErrStalePrimary, SCTPathRelated, SCPathAsymAccessTransition, true},
|
||||
|
||||
@@ -54,6 +54,7 @@ stateDiagram-v2
|
||||
| From | To | Guard | Enforced in | Protects |
|
||||
|---|---|---|---|---|
|
||||
| — | Opened | v3 A/B descriptors and owned-map dependencies valid, exclusive file ownership acquired; legacy formats refused; backend starts not operational | `core/storage/walstore.go` `OpenWALStoreWithOptions`; `core/frontend/durable/provider.go` `openOrCreate` | `INV-WAL-OPGATE-001` |
|
||||
| `INV-FE-NVME-READY-001` | An NVMe I/O refused with `ErrNotReady` returns Namespace Not Ready (SC0x82), DNR=0, without reading or mutating storage; closed/stale lineage retain their ANA errors and physical I/O faults retain Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `readyCheck`; `core/frontend/nvme/io.go` `mapBackendError` | `TestWALStoreChunk_TakeoverReadBeforeAttachIsRetryable`; `TestSessionReadNotReadyIsRetryable` | — | ACTIVE |
|
||||
| Opened | Recovering | the volume is open in the provider | `core/frontend/durable/provider.go` `RecoverVolume` | `INV-WAL-OPGATE-001` |
|
||||
| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end (legacy LSN scan remains fixture-only) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001` |
|
||||
| Recovering | RecoveryFailed | a WAL integrity failure or an I/O error; the backend stays not operational and the host blocks local readiness with `wal_corrupt` or `io_error` | `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`; `core/host/volume/recovery_watchdog.go` `LocalRecoveryHealthReason` | `INV-WAL-TYPED-FAILCLOSED-001`, `INV-WAL-OPGATE-001` |
|
||||
|
||||
Reference in new issue
Block a user