storagefsm: Fix race spawning more than one new sector at once
This commit is contained in:
parent
9475079b97
commit
6e1919c67f
10
extern/storage-sealing/input.go
vendored
10
extern/storage-sealing/input.go
vendored
@ -27,6 +27,10 @@ func (m *Sealing) handleWaitDeals(ctx statemachine.Context, sector SectorInfo) e
|
||||
|
||||
m.inputLk.Lock()
|
||||
|
||||
if m.creating != nil && *m.creating == sector.SectorNumber {
|
||||
m.creating = nil
|
||||
}
|
||||
|
||||
sid := m.minerSectorID(sector.SectorNumber)
|
||||
|
||||
if len(m.assignedPieces[sid]) > 0 {
|
||||
@ -390,6 +394,10 @@ func (m *Sealing) updateInput(ctx context.Context, sp abi.RegisteredSealProof) e
|
||||
}
|
||||
|
||||
func (m *Sealing) tryCreateDealSector(ctx context.Context, sp abi.RegisteredSealProof) error {
|
||||
if m.creating != nil {
|
||||
return nil // new sector is being created right now
|
||||
}
|
||||
|
||||
cfg, err := m.getConfig()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getting storage config: %w", err)
|
||||
@ -408,6 +416,8 @@ func (m *Sealing) tryCreateDealSector(ctx context.Context, sp abi.RegisteredSeal
|
||||
return err
|
||||
}
|
||||
|
||||
m.creating = &sid
|
||||
|
||||
log.Infow("Creating sector", "number", sid, "type", "deal", "proofType", sp)
|
||||
return m.sectors.Send(uint64(sid), SectorStart{
|
||||
ID: sid,
|
||||
|
1
extern/storage-sealing/sealing.go
vendored
1
extern/storage-sealing/sealing.go
vendored
@ -93,6 +93,7 @@ type Sealing struct {
|
||||
sectorTimers map[abi.SectorID]*time.Timer
|
||||
pendingPieces map[cid.Cid]*pendingPiece
|
||||
assignedPieces map[abi.SectorID][]cid.Cid
|
||||
creating *abi.SectorNumber // used to prevent a race where we could create a new sector more than once
|
||||
|
||||
upgradeLk sync.Mutex
|
||||
toUpgrade map[abi.SectorNumber]struct{}
|
||||
|
Loading…
Reference in New Issue
Block a user