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++ }