From e5b5bf1c1ba0c49dc2079165be48725d63dd3796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 12 Mar 2021 17:25:24 +0100 Subject: [PATCH] storagefsm: Update sector stats atomically with sector creation --- api/test/deals.go | 4 ++-- extern/storage-sealing/garbage.go | 3 +++ extern/storage-sealing/input.go | 3 +++ extern/storage-sealing/stats.go | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/test/deals.go b/api/test/deals.go index 4f710cb71..7a9454bae 100644 --- a/api/test/deals.go +++ b/api/test/deals.go @@ -203,8 +203,8 @@ func TestBatchDealInput(t *testing.T, b APIBuilder, blocktime time.Duration, sta return func() (sealiface.Config, error) { return sealiface.Config{ MaxWaitDealsSectors: 1, - MaxSealingSectors: 2, - MaxSealingSectorsForDeals: 3, + MaxSealingSectors: 1, + MaxSealingSectorsForDeals: 2, AlwaysKeepUnsealedCopy: true, }, nil }, nil diff --git a/extern/storage-sealing/garbage.go b/extern/storage-sealing/garbage.go index 398040e6e..9409dca36 100644 --- a/extern/storage-sealing/garbage.go +++ b/extern/storage-sealing/garbage.go @@ -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) } + // update stats early, fsm planner would do that async + m.stats.updateSector(cfg, m.minerSectorID(sid), UndefinedSectorState) + log.Infof("Creating CC sector %d", sid) return sectorID, m.sectors.Send(uint64(sid), SectorStartCC{ ID: sid, diff --git a/extern/storage-sealing/input.go b/extern/storage-sealing/input.go index 564afbc88..756770121 100644 --- a/extern/storage-sealing/input.go +++ b/extern/storage-sealing/input.go @@ -400,6 +400,9 @@ func (m *Sealing) tryCreateDealSector(ctx context.Context, sp abi.RegisteredSeal 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) return m.sectors.Send(uint64(sid), SectorStart{ ID: sid, diff --git a/extern/storage-sealing/stats.go b/extern/storage-sealing/stats.go index e858519fd..2688d8494 100644 --- a/extern/storage-sealing/stats.go +++ b/extern/storage-sealing/stats.go @@ -45,6 +45,8 @@ func (ss *SectorStats) updateSector(cfg sealiface.Config, id abi.SectorID, st Se sealing := ss.curSealingLocked() staging := ss.curStagingLocked() + log.Debugw("sector stats", "sealing", sealing, "staging", staging) + if cfg.MaxSealingSectorsForDeals > 0 && // max sealing deal sector limit set preSealing >= cfg.MaxSealingSectorsForDeals && // we were over limit sealing < cfg.MaxSealingSectorsForDeals { // and we're below the limit now