From 716b4cc6521c0d2336392afed0c31e4d5dec42f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 8 Dec 2019 20:48:17 +0100 Subject: [PATCH] Restart fPoSt after fail --- storage/fpost_run.go | 11 +++++++++++ storage/fpost_sched.go | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/storage/fpost_run.go b/storage/fpost_run.go index f3c031279..5f453188b 100644 --- a/storage/fpost_run.go +++ b/storage/fpost_run.go @@ -14,6 +14,14 @@ import ( "github.com/filecoin-project/lotus/lib/sectorbuilder" ) +func (s *fpostScheduler) failPost(eps uint64) { + s.failLk.Lock() + if eps > s.failed { + s.failed = eps + } + s.failLk.Unlock() +} + func (s *fpostScheduler) doPost(ctx context.Context, eps uint64, ts *types.TipSet) { ctx, abort := context.WithCancel(ctx) @@ -29,13 +37,16 @@ func (s *fpostScheduler) doPost(ctx context.Context, eps uint64, ts *types.TipSe proof, err := s.runPost(ctx, eps, ts) if err != nil { log.Errorf("runPost failed: %+v", err) + s.failPost(eps) return } if err := s.submitPost(ctx, proof); err != nil { log.Errorf("submitPost failed: %+v", err) + s.failPost(eps) return } + }() } diff --git a/storage/fpost_sched.go b/storage/fpost_sched.go index 886c79c49..58cca22ef 100644 --- a/storage/fpost_sched.go +++ b/storage/fpost_sched.go @@ -2,6 +2,7 @@ package storage import ( "context" + "sync" "go.opencensus.io/trace" "golang.org/x/xerrors" @@ -29,6 +30,9 @@ type fpostScheduler struct { // if a post is in progress, this indicates for which ElectionPeriodStart activeEPS uint64 abort context.CancelFunc + + failed uint64 // eps + failLk sync.Mutex } func (s *fpostScheduler) run(ctx context.Context) { @@ -111,6 +115,13 @@ func (s *fpostScheduler) update(ctx context.Context, new *types.TipSet) error { return err } + s.failLk.Lock() + if s.failed > 0 { + s.failed = 0 + s.activeEPS = 0 + } + s.failLk.Unlock() + if newEPS == s.activeEPS { return nil }