From 33f7746296a6e9fa5b3d6dc0429e96d767807dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 7 Nov 2022 16:31:53 +0000 Subject: [PATCH] fix: sealing pipeine: Release assigned deals on snapdeals abort --- storage/pipeline/states_failed.go | 2 ++ storage/pipeline/states_proving.go | 6 ++++++ storage/pipeline/states_sealing.go | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/storage/pipeline/states_failed.go b/storage/pipeline/states_failed.go index b90833b2df2..ed7ba89f3c2 100644 --- a/storage/pipeline/states_failed.go +++ b/storage/pipeline/states_failed.go @@ -421,6 +421,8 @@ func (m *Sealing) handleAbortUpgrade(ctx statemachine.Context, sector SectorInfo return xerrors.Errorf("should never reach AbortUpgrade as a non-CCUpdate sector") } + m.cleanupAssignedDeals(sector) + // Remove snap deals replica if any if err := m.sealer.ReleaseReplicaUpgrade(ctx.Context(), m.minerSector(sector.SectorType, sector.SectorNumber)); err != nil { return xerrors.Errorf("removing CC update files from sector storage") diff --git a/storage/pipeline/states_proving.go b/storage/pipeline/states_proving.go index f4b957249cf..bed61a452a1 100644 --- a/storage/pipeline/states_proving.go +++ b/storage/pipeline/states_proving.go @@ -138,6 +138,12 @@ func (m *Sealing) handleProvingSector(ctx statemachine.Context, sector SectorInf delete(m.available, m.minerSectorID(sector.SectorNumber)) m.inputLk.Unlock() + // guard against manual state updates from snap-deals states into Proving + // note: normally snap deals should be aborted through the abort command, but + // apparently sometimes some SPs would use update-state to force the sector back + // into the Proving state, breaking the deal input pipeline in the process. + m.cleanupAssignedDeals(sector) + // TODO: Watch termination // TODO: Auto-extend if set diff --git a/storage/pipeline/states_sealing.go b/storage/pipeline/states_sealing.go index b40a9bf45b3..5b5d2e37267 100644 --- a/storage/pipeline/states_sealing.go +++ b/storage/pipeline/states_sealing.go @@ -33,7 +33,7 @@ import ( var DealSectorPriority = 1024 var MaxTicketAge = policy.MaxPreCommitRandomnessLookback -func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) error { +func (m *Sealing) cleanupAssignedDeals(sector SectorInfo) { m.inputLk.Lock() // make sure we are not accepting deals into this sector for _, c := range m.assignedPieces[m.minerSectorID(sector.SectorNumber)] { @@ -51,6 +51,10 @@ func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) err delete(m.openSectors, m.minerSectorID(sector.SectorNumber)) delete(m.assignedPieces, m.minerSectorID(sector.SectorNumber)) m.inputLk.Unlock() +} + +func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) error { + m.cleanupAssignedDeals(sector) // if this is a snapdeals sector, but it ended up not having any deals, abort the upgrade if sector.State == SnapDealsPacking && !sector.hasDeals() {