mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
5ca1d1193e5ea72c689c628363d7c22bc15a4433
Per T4d mini-plan v0.3 §2.1 (architect-ratified). Closes T4c §I forward-carry "structured RecoveryFailureKind" + lands the LogicalStorage AppliedLSNs() addition T4d-2 needs at session start. ARCHITECTURAL CONTRACT (v0.3 boundary discipline): - core/engine MUST NOT import core/storage - storage owns substrate-side StorageRecoveryFailureKind + RecoveryFailure - transport extracts substrate kind via errors.As, maps to engine kind - adapter.SessionCloseResult.FailureKind = engine.RecoveryFailureKind - engine.SessionClosedFailed.FailureKind = engine.RecoveryFailureKind - Reason / FailReason text remains DIAGNOSTIC ONLY — engine MUST NOT parse Storage side (core/storage/recovery_contract.go): - StorageRecoveryFailureKind enum (Unknown / WALRecycled / SubstrateIO) - RecoveryFailure typed-error struct with Unwrap() preserving errors.Is(_, ErrWALRecycled) compatibility for migration window - NewWALRecycledFailure / NewSubstrateIOFailure helpers - ErrAppliedLSNsNotTracked sentinel for substrates without per-LBA applied-LSN metadata LogicalStorage interface gains AppliedLSNs() method (Option C hybrid per kickoff §2.5 #1 architect ratification): - BlockStore: explicit (nil, ErrAppliedLSNsNotTracked) — in-memory, no per-LBA tracking; gate falls back to session-only map - walstore: dirty-map snapshot reduction (PARTIAL VIEW per kickoff §2.5 #3 caveat — only in-WAL LBAs reported; flushed LBAs lose per-LBA LSN tracking; defense-in-depth, gate is authoritative) - smartwal: ring.scanValid() per-LBA last-writer-wins reduction Substrate ScanLBAs error wrapping: - walstore: NewWALRecycledFailure(ErrWALRecycled, "fromLSN=... checkpointLSN=...") at retention boundary - smartwal: NewWALRecycledFailure(ErrWALRecycled, "fromLSN=... oldestPreserved=...") at retention boundary Engine side (core/engine/events.go + apply.go): - New engine-owned RecoveryFailureKind enum (Unknown / WALRecycled / Transport / SubstrateIO / TargetNotReached / StartTimeout / SessionInvalidated) - SessionClosedFailed gains FailureKind field (typed branch) - applySessionFailed branches on e.FailureKind, NOT on Reason text - Substring helpers REMOVED: isWALRecycledFailure / isStartTimeoutFailure / containsAny — engine no longer parses Reason Transport side (core/transport/recovery_session.go + executor.go finishSession): - New classifyRecoveryFailure helper at the boundary: errors.As to extract *storage.RecoveryFailure, map StorageRecoveryFailureKind → engine.RecoveryFailureKind; fallbacks for errSessionInvalidated + target-not-reached error message (transport-internal, acceptable) - finishSession populates SessionCloseResult.FailureKind via classifier Adapter side (core/adapter/normalize.go + adapter.go): - SessionCloseResult gains FailureKind engine.RecoveryFailureKind - NormalizeSessionClose copies FailureKind into SessionClosedFailed - adapter dispatch failure paths (start_catchup_failed / start_rebuild_failed / start_recovery_failed) tag Transport kind - Watchdog timeout path tags StartTimeout kind (engine bypasses retry for this kind per existing T4c-3 design) Tests (10 new, mini-plan §2.1 budget met): - Storage: TestStorageRecoveryFailure_WALRecycled_ErrorsIsCompatible, TestStorageRecoveryFailure_WALRecycled_ErrorsAsExposesKind, TestStorageRecoveryFailure_SubstrateIO_ErrorsAsExposesKind, TestStorageRecoveryFailureKind_StringForms, TestBlockStore_AppliedLSNs_ReturnsErrAppliedLSNsNotTracked, TestStorageRecoveryFailureKind_Walstore_RecycleWrappedAsKind, TestWalstore_AppliedLSNs_ReportsDirtyMapEntries, TestStorageRecoveryFailureKind_Smartwal_RecycleWrappedAsKind, TestSmartwal_AppliedLSNs_ReportsRingEntries - Adapter: TestAdapter_SessionCloseResult_TypedKindEndToEnd (×6 subtests, one per kind), TestAdapter_SessionCloseResult_ SuccessIgnoresFailureKind - Engine: TestSessionFailed_WALRecycled_EscalatesToRebuild (rewritten — typed branch), TestSessionFailed_WALRecycled_ NoSubstringMatchUsed (negative pin: text-only without typed kind must NOT escalate), TestEngine_SessionFailed_NoMoreSubstringMatch (source-grep fence with comment-stripping helper to avoid false-positive on godoc mentions of removed helpers) Existing tests preserved: - T4c-2 / T4c-3 tests pass under new contract (existing close-result builders default FailureKind to Unknown which falls into the Transport-kind retry path — matches their pre-T4d-1 substring- match behavior on non-recycled failures) INV-REPL-CATCHUP-RECYCLE-ESCALATES updated: pinning method changed from substring to typed kind (per T4d mini-plan §2.1). go test ./... -count=1 → all 22 packages green. Refs: T4d mini-plan v0.3 (architect-ratified 2026-04-25); kickoff §9.3 #1 (Q1 engine-owned recovery decisions); kickoff §2.5 #1 (Option C hybrid AppliedLSNs); memory feedback_engine_no_storage_ import.md (round-45 architect lock). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%