Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sealing pipeine: Release assigned deals on snapdeals abort #9601

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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