Merge pull request #797 from filecoin-project/fix/fpost-restart

Restart fPoSt after fail
This commit is contained in:
Łukasz Magiera
2019-12-08 23:20:48 +01:00
committed by GitHub
2 changed files with 22 additions and 0 deletions
+11
View File
@@ -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
}
}()
}
+11
View File
@@ -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
}