storagefsm: Treat PackingFailed sectors as expired

This commit is contained in:
Łukasz Magiera 2020-08-27 22:41:35 +02:00
parent 6c7874c883
commit d8e58e67c6
7 changed files with 15 additions and 9 deletions

View File

@ -267,6 +267,7 @@ var stateList = []stateMeta{
{col: color.FgRed, state: sealing.FaultedFinal}, {col: color.FgRed, state: sealing.FaultedFinal},
{col: color.FgRed, state: sealing.RemoveFailed}, {col: color.FgRed, state: sealing.RemoveFailed},
{col: color.FgRed, state: sealing.DealsExpired}, {col: color.FgRed, state: sealing.DealsExpired},
{col: color.FgRed, state: sealing.RecoverDealIDs},
} }
func init() { func init() {

View File

@ -49,13 +49,12 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
PreCommit1: planOne( PreCommit1: planOne(
on(SectorPreCommit1{}, PreCommit2), on(SectorPreCommit1{}, PreCommit2),
on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed),
on(SectorPackingFailed{}, PackingFailed), on(SectorDealsExpired{}, DealsExpired),
on(SectorInvalidDealIDs{}, RecoverDealIDs), on(SectorInvalidDealIDs{}, RecoverDealIDs),
), ),
PreCommit2: planOne( PreCommit2: planOne(
on(SectorPreCommit2{}, PreCommitting), on(SectorPreCommit2{}, PreCommitting),
on(SectorSealPreCommit2Failed{}, SealPreCommit2Failed), on(SectorSealPreCommit2Failed{}, SealPreCommit2Failed),
on(SectorPackingFailed{}, PackingFailed),
), ),
PreCommitting: planOne( PreCommitting: planOne(
on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed),
@ -126,6 +125,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
FinalizeFailed: planOne( FinalizeFailed: planOne(
on(SectorRetryFinalize{}, FinalizeSector), on(SectorRetryFinalize{}, FinalizeSector),
), ),
PackingFailed: planOne(), // TODO: Deprecated, remove
DealsExpired: planOne( DealsExpired: planOne(
// SectorRemove (global) // SectorRemove (global)
), ),
@ -290,6 +290,9 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta
return m.handleCommitFailed, processed, nil return m.handleCommitFailed, processed, nil
case FinalizeFailed: case FinalizeFailed:
return m.handleFinalizeFailed, processed, nil return m.handleFinalizeFailed, processed, nil
case PackingFailed: // DEPRECATED: remove this for the next reset
state.State = DealsExpired
fallthrough
case DealsExpired: case DealsExpired:
return m.handleDealsExpired, processed, nil return m.handleDealsExpired, processed, nil

View File

@ -101,10 +101,6 @@ func (evt SectorPacked) apply(state *SectorInfo) {
} }
} }
type SectorPackingFailed struct{ error }
func (evt SectorPackingFailed) apply(*SectorInfo) {}
type SectorPreCommit1 struct { type SectorPreCommit1 struct {
PreCommit1Out storage.PreCommit1Out PreCommit1Out storage.PreCommit1Out
TicketValue abi.SealRandomness TicketValue abi.SealRandomness

View File

@ -58,6 +58,9 @@ func TestHappyPath(t *testing.T) {
require.Equal(m.t, m.state.State, Committing) require.Equal(m.t, m.state.State, Committing)
m.planSingle(SectorCommitted{}) m.planSingle(SectorCommitted{})
require.Equal(m.t, m.state.State, SubmitCommit)
m.planSingle(SectorCommitSubmitted{})
require.Equal(m.t, m.state.State, CommitWait) require.Equal(m.t, m.state.State, CommitWait)
m.planSingle(SectorProving{}) m.planSingle(SectorProving{})
@ -105,6 +108,9 @@ func TestSeedRevert(t *testing.T) {
// not changing the seed this time // not changing the seed this time
_, _, err = m.s.plan([]statemachine.Event{{User: SectorSeedReady{SeedValue: nil, SeedEpoch: 5}}, {User: SectorCommitted{}}}, m.state) _, _, err = m.s.plan([]statemachine.Event{{User: SectorSeedReady{SeedValue: nil, SeedEpoch: 5}}, {User: SectorCommitted{}}}, m.state)
require.NoError(t, err) require.NoError(t, err)
require.Equal(m.t, m.state.State, SubmitCommit)
m.planSingle(SectorCommitSubmitted{})
require.Equal(m.t, m.state.State, CommitWait) require.Equal(m.t, m.state.State, CommitWait)
m.planSingle(SectorProving{}) m.planSingle(SectorProving{})

View File

@ -26,7 +26,7 @@ const (
PreCommitFailed SectorState = "PreCommitFailed" PreCommitFailed SectorState = "PreCommitFailed"
ComputeProofFailed SectorState = "ComputeProofFailed" ComputeProofFailed SectorState = "ComputeProofFailed"
CommitFailed SectorState = "CommitFailed" CommitFailed SectorState = "CommitFailed"
PackingFailed SectorState = "PackingFailed" PackingFailed SectorState = "PackingFailed" // TODO: deprecated, remove
FinalizeFailed SectorState = "FinalizeFailed" FinalizeFailed SectorState = "FinalizeFailed"
DealsExpired SectorState = "DealsExpired" DealsExpired SectorState = "DealsExpired"
RecoverDealIDs SectorState = "RecoverDealIDs" RecoverDealIDs SectorState = "RecoverDealIDs"

View File

@ -258,7 +258,7 @@ func (m *Sealing) handleDealsExpired(ctx statemachine.Context, sector SectorInfo
if sector.PreCommitInfo == nil { if sector.PreCommitInfo == nil {
// TODO: Create a separate state which will remove those pieces, and go back to PC1 // TODO: Create a separate state which will remove those pieces, and go back to PC1
return xerrors.Errorf("non-precommitted sector with expired deals, can't recover from this yet") log.Errorf("non-precommitted sector with expired deals, can't recover from this yet")
} }
// Not much to do here, we can't go back in time to commit this sector // Not much to do here, we can't go back in time to commit this sector

View File

@ -89,7 +89,7 @@ func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo)
log.Warnf("invalid deals in sector %d: %v", sector.SectorNumber, err) log.Warnf("invalid deals in sector %d: %v", sector.SectorNumber, err)
return ctx.Send(SectorInvalidDealIDs{ Return: RetPreCommit1 }) return ctx.Send(SectorInvalidDealIDs{ Return: RetPreCommit1 })
case *ErrExpiredDeals: // Probably not much we can do here, maybe re-pack the sector? case *ErrExpiredDeals: // Probably not much we can do here, maybe re-pack the sector?
return ctx.Send(SectorPackingFailed{xerrors.Errorf("expired dealIDs in sector: %w", err)}) return ctx.Send(SectorDealsExpired{xerrors.Errorf("expired dealIDs in sector: %w", err)})
default: default:
return xerrors.Errorf("checkPieces sanity check error: %w", err) return xerrors.Errorf("checkPieces sanity check error: %w", err)
} }