storagefsm: Fix some deadlock cases

This commit is contained in:
Łukasz Magiera 2021-01-19 19:04:05 +01:00
parent e5814dac4f
commit 9857ad8378
2 changed files with 12 additions and 7 deletions

View File

@ -28,6 +28,8 @@ func (m *Sealing) handleWaitDeals(ctx statemachine.Context, sector SectorInfo) e
st := m.sectorTimers[m.minerSectorID(sector.SectorNumber)]
if st != nil {
if !st.Stop() { // timer expired, SectorStartPacking was/is being sent
m.inputLk.Unlock()
// we send another SectorStartPacking in case one was sent in the handleAddPiece state
return ctx.Send(SectorStartPacking{})
}
@ -36,20 +38,22 @@ func (m *Sealing) handleWaitDeals(ctx statemachine.Context, sector SectorInfo) e
if !sector.CreationTime.IsZero() {
cfg, err := m.getConfig()
if err != nil {
m.inputLk.Unlock()
return xerrors.Errorf("getting storage config: %w", err)
}
sealTime := sector.CreationTime.Add(cfg.WaitDealsDelay)
if now.After(sealTime) {
m.inputLk.Unlock()
return ctx.Send(SectorStartPacking{})
} else {
}
m.sectorTimers[m.minerSectorID(sector.SectorNumber)] = time.AfterFunc(sealTime.Sub(now), func() {
if err := ctx.Send(SectorStartPacking{}); err != nil {
log.Errorw("sending SectorStartPacking event failed", "sector", sector.SectorNumber, "error", err)
}
})
}
}
var used abi.UnpaddedPieceSize
for _, piece := range sector.Pieces {

View File

@ -3,9 +3,10 @@ package sealing
import (
"bytes"
"context"
"github.com/ipfs/go-cid"
"time"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/exitcode"