Skip to content

Commit

Permalink
Merge pull request #7444 from filecoin-project/feat/ap-fail-retry
Browse files Browse the repository at this point in the history
sealing: Recover sectors after failed AddPiece
  • Loading branch information
magik6k authored Oct 7, 2021
2 parents e74f703 + cadbd00 commit 1993efe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion extern/storage-sealing/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions extern/storage-sealing/fsm_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
4 changes: 1 addition & 3 deletions extern/storage-sealing/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion extern/storage-sealing/sector_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1993efe

Please sign in to comment.