Skip to content

Commit

Permalink
fix: sealing pipeine: Release assigned deals on snapdeals abort
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Nov 7, 2022
1 parent abfabd2 commit 33f7746
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions storage/pipeline/states_failed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions storage/pipeline/states_proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion storage/pipeline/states_sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)] {
Expand All @@ -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() {
Expand Down

0 comments on commit 33f7746

Please sign in to comment.