diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index edefacf4d..f14d307ab 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -307,6 +307,7 @@ var stateList = []stateMeta{ {col: color.FgCyan, state: sealing.Removed}, {col: color.FgRed, state: sealing.FailedUnrecoverable}, + {col: color.FgRed, state: sealing.AddPieceFailed}, {col: color.FgRed, state: sealing.SealPreCommit1Failed}, {col: color.FgRed, state: sealing.SealPreCommit2Failed}, {col: color.FgRed, state: sealing.PreCommitFailed}, diff --git a/extern/storage-sealing/fsm.go b/extern/storage-sealing/fsm.go index a1739a1cc..c38101e6c 100644 --- a/extern/storage-sealing/fsm.go +++ b/extern/storage-sealing/fsm.go @@ -51,6 +51,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto AddPiece: planOne( on(SectorPieceAdded{}, WaitDeals), apply(SectorStartPacking{}), + on(SectorAddPieceFailed{}, AddPieceFailed), ), Packing: planOne(on(SectorPacked{}, GetTicket)), GetTicket: planOne( @@ -104,6 +105,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto // Sealing errors + AddPieceFailed: planOne(), SealPreCommit1Failed: planOne( on(SectorRetrySealPreCommit1{}, PreCommit1), ), diff --git a/extern/storage-sealing/fsm_events.go b/extern/storage-sealing/fsm_events.go index 98cf18308..14015c2d8 100644 --- a/extern/storage-sealing/fsm_events.go +++ b/extern/storage-sealing/fsm_events.go @@ -95,6 +95,11 @@ func (evt SectorPieceAdded) apply(state *SectorInfo) { state.Pieces = append(state.Pieces, evt.NewPieces...) } +type SectorAddPieceFailed struct{ error } + +func (evt SectorAddPieceFailed) FormatError(xerrors.Printer) (next error) { return evt.error } +func (evt SectorAddPieceFailed) 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 89cd27176..51e4356fa 100644 --- a/extern/storage-sealing/input.go +++ b/extern/storage-sealing/input.go @@ -117,7 +117,7 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er } m.inputLk.Unlock() if !ok { - // nothing to do here + // nothing to do here (might happen after a restart in AddPiece) return ctx.Send(res) } @@ -166,7 +166,7 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er if err != nil { err = xerrors.Errorf("writing padding piece: %w", err) deal.accepted(sector.SectorNumber, offset, err) - return err // todo failed state + return ctx.Send(SectorAddPieceFailed{err}) } pieceSizes = append(pieceSizes, p.Unpadded()) @@ -183,7 +183,7 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er if err != nil { err = xerrors.Errorf("writing piece: %w", err) deal.accepted(sector.SectorNumber, offset, err) - return err // todo failed state + return ctx.Send(SectorAddPieceFailed{err}) } deal.accepted(sector.SectorNumber, offset, nil) @@ -200,6 +200,12 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er return ctx.Send(res) } +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 +} + func (m *Sealing) AddPieceToAnySector(ctx context.Context, size abi.UnpaddedPieceSize, data storage.Data, deal DealInfo) (abi.SectorNumber, abi.PaddedPieceSize, error) { log.Infof("Adding piece for deal %d (publish msg: %s)", deal.DealID, deal.PublishCid) if (padreader.PaddedSize(uint64(size))) != size { diff --git a/extern/storage-sealing/sector_state.go b/extern/storage-sealing/sector_state.go index da3db401b..ae5b4fab2 100644 --- a/extern/storage-sealing/sector_state.go +++ b/extern/storage-sealing/sector_state.go @@ -7,6 +7,7 @@ var ExistSectorStateList = map[SectorState]struct{}{ WaitDeals: {}, Packing: {}, AddPiece: {}, + AddPieceFailed: {}, GetTicket: {}, PreCommit1: {}, PreCommit2: {}, @@ -61,6 +62,7 @@ const ( Proving SectorState = "Proving" // error modes FailedUnrecoverable SectorState = "FailedUnrecoverable" + AddPieceFailed SectorState = "AddPieceFailed" SealPreCommit1Failed SectorState = "SealPreCommit1Failed" SealPreCommit2Failed SectorState = "SealPreCommit2Failed" PreCommitFailed SectorState = "PreCommitFailed"