From cadbd00ac4b103a4d878745ba55d1ba0915ec579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 4 Oct 2021 20:00:07 +0200 Subject: [PATCH] sealing: Recover sectors after failed AddPiece --- extern/storage-sealing/fsm.go | 8 +++++++- extern/storage-sealing/fsm_events.go | 4 ++++ extern/storage-sealing/input.go | 4 +--- extern/storage-sealing/sector_state.go | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/extern/storage-sealing/fsm.go b/extern/storage-sealing/fsm.go index 290aba53b25..00e38694dc4 100644 --- a/extern/storage-sealing/fsm.go +++ b/extern/storage-sealing/fsm.go @@ -135,7 +135,11 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto // Sealing errors - AddPieceFailed: planOne(), + AddPieceFailed: planOne( + on(SectorRetryWaitDeals{}, WaitDeals), + apply(SectorStartPacking{}), + apply(SectorAddPiece{}), + ), SealPreCommit1Failed: planOne( on(SectorRetrySealPreCommit1{}, PreCommit1), ), @@ -400,6 +404,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta return m.handleFinalizeSector, processed, nil // Handled failure modes + case AddPieceFailed: + return m.handleAddPieceFailed, processed, nil case SealPreCommit1Failed: return m.handleSealPrecommit1Failed, processed, nil case SealPreCommit2Failed: diff --git a/extern/storage-sealing/fsm_events.go b/extern/storage-sealing/fsm_events.go index 3dab6d40356..650a817995e 100644 --- a/extern/storage-sealing/fsm_events.go +++ b/extern/storage-sealing/fsm_events.go @@ -98,6 +98,10 @@ type SectorAddPieceFailed struct{ error } func (evt SectorAddPieceFailed) FormatError(xerrors.Printer) (next error) { return evt.error } func (evt SectorAddPieceFailed) apply(si *SectorInfo) {} +type SectorRetryWaitDeals struct{} + +func (evt SectorRetryWaitDeals) apply(si *SectorInfo) {} + type SectorStartPacking struct{} func (evt SectorStartPacking) apply(*SectorInfo) {} diff --git a/extern/storage-sealing/input.go b/extern/storage-sealing/input.go index 361907b2753..b69cf8c19ea 100644 --- a/extern/storage-sealing/input.go +++ b/extern/storage-sealing/input.go @@ -245,9 +245,7 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er } func (m *Sealing) handleAddPieceFailed(ctx statemachine.Context, sector SectorInfo) error { - log.Errorf("No recovery plan for AddPiece failing") - // todo: cleanup sector / just go retry (requires adding offset param to AddPiece in sector-storage for this to be safe) - return nil + return ctx.Send(SectorRetryWaitDeals{}) } func (m *Sealing) SectorAddPieceToAny(ctx context.Context, size abi.UnpaddedPieceSize, data storage.Data, deal api.PieceDealInfo) (api.SectorOffset, error) { diff --git a/extern/storage-sealing/sector_state.go b/extern/storage-sealing/sector_state.go index 34a0c6bbef8..b606de5aeb5 100644 --- a/extern/storage-sealing/sector_state.go +++ b/extern/storage-sealing/sector_state.go @@ -108,7 +108,7 @@ const ( func toStatState(st SectorState, finEarly bool) statSectorState { switch st { - case UndefinedSectorState, Empty, WaitDeals, AddPiece: + case UndefinedSectorState, Empty, WaitDeals, AddPiece, AddPieceFailed: return sstStaging case Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, SubmitPreCommitBatch, PreCommitBatchWait, WaitSeed, Committing, CommitFinalize, FinalizeSector: return sstSealing