storagefsm: Update sector stats atomically with sector creation

This commit is contained in:
Łukasz Magiera 2021-03-12 17:25:24 +01:00
parent 679f5f7661
commit e5b5bf1c1b
4 changed files with 10 additions and 2 deletions

View File

@ -203,8 +203,8 @@ func TestBatchDealInput(t *testing.T, b APIBuilder, blocktime time.Duration, sta
return func() (sealiface.Config, error) { return func() (sealiface.Config, error) {
return sealiface.Config{ return sealiface.Config{
MaxWaitDealsSectors: 1, MaxWaitDealsSectors: 1,
MaxSealingSectors: 2, MaxSealingSectors: 1,
MaxSealingSectorsForDeals: 3, MaxSealingSectorsForDeals: 2,
AlwaysKeepUnsealedCopy: true, AlwaysKeepUnsealedCopy: true,
}, nil }, nil
}, nil }, nil

View File

@ -38,6 +38,9 @@ func (m *Sealing) PledgeSector(ctx context.Context) (storage.SectorRef, error) {
return storage.SectorRef{}, xerrors.Errorf("notifying sealer of the new sector: %w", err) return storage.SectorRef{}, xerrors.Errorf("notifying sealer of the new sector: %w", err)
} }
// update stats early, fsm planner would do that async
m.stats.updateSector(cfg, m.minerSectorID(sid), UndefinedSectorState)
log.Infof("Creating CC sector %d", sid) log.Infof("Creating CC sector %d", sid)
return sectorID, m.sectors.Send(uint64(sid), SectorStartCC{ return sectorID, m.sectors.Send(uint64(sid), SectorStartCC{
ID: sid, ID: sid,

View File

@ -400,6 +400,9 @@ func (m *Sealing) tryCreateDealSector(ctx context.Context, sp abi.RegisteredSeal
return xerrors.Errorf("initializing sector: %w", err) return xerrors.Errorf("initializing sector: %w", err)
} }
// update stats early, fsm planner would do that async
m.stats.updateSector(cfg, m.minerSectorID(sid), UndefinedSectorState)
log.Infow("Creating sector", "number", sid, "type", "deal", "proofType", sp) log.Infow("Creating sector", "number", sid, "type", "deal", "proofType", sp)
return m.sectors.Send(uint64(sid), SectorStart{ return m.sectors.Send(uint64(sid), SectorStart{
ID: sid, ID: sid,

View File

@ -45,6 +45,8 @@ func (ss *SectorStats) updateSector(cfg sealiface.Config, id abi.SectorID, st Se
sealing := ss.curSealingLocked() sealing := ss.curSealingLocked()
staging := ss.curStagingLocked() staging := ss.curStagingLocked()
log.Debugw("sector stats", "sealing", sealing, "staging", staging)
if cfg.MaxSealingSectorsForDeals > 0 && // max sealing deal sector limit set if cfg.MaxSealingSectorsForDeals > 0 && // max sealing deal sector limit set
preSealing >= cfg.MaxSealingSectorsForDeals && // we were over limit preSealing >= cfg.MaxSealingSectorsForDeals && // we were over limit
sealing < cfg.MaxSealingSectorsForDeals { // and we're below the limit now sealing < cfg.MaxSealingSectorsForDeals { // and we're below the limit now