From 3feb9167cbbdbfd36be30abb05490cc9cb92f096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 1 Aug 2022 16:58:05 +0200 Subject: [PATCH] feat: wdpost: Envvar for limiting recovering sectors --- storage/wdpost/wdpost_run_faults.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/storage/wdpost/wdpost_run_faults.go b/storage/wdpost/wdpost_run_faults.go index 60352e8b8..b5a52c1ed 100644 --- a/storage/wdpost/wdpost_run_faults.go +++ b/storage/wdpost/wdpost_run_faults.go @@ -2,6 +2,8 @@ package wdpost import ( "context" + "os" + "strconv" "github.com/ipfs/go-cid" "go.opencensus.io/trace" @@ -19,6 +21,18 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) +var recoveringSectorLimit int64 = 0 + +func init() { + if rcl := os.Getenv("LOTUS_RECOVERING_SECTOR_LIMIT"); rcl != "" { + var err error + recoveringSectorLimit, err = strconv.ParseInt(rcl, 10, 64) + if err != nil { + log.Errorw("parsing LOTUS_RECOVERING_SECTOR_LIMIT", "error", err) + } + } +} + // declareRecoveries identifies sectors that were previously marked as faulty // for our miner, but are now recovered (i.e. are now provable again) and // still not reported as such. @@ -90,6 +104,11 @@ func (s *WindowPoStScheduler) declareRecoveries(ctx context.Context, dlIdx uint6 Sectors: recovered, }) + if recoveringSectorLimit > 0 && int64(totalRecoveries) >= recoveringSectorLimit { + log.Errorw("reached recovering sector limit, not all sectors will be marked as recovered") + break + } + totalRecoveries++ }