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
commit 51afeb0588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -14,6 +14,14 @@ import (
"github.com/filecoin-project/lotus/lib/sectorbuilder" "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) { func (s *fpostScheduler) doPost(ctx context.Context, eps uint64, ts *types.TipSet) {
ctx, abort := context.WithCancel(ctx) 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) proof, err := s.runPost(ctx, eps, ts)
if err != nil { if err != nil {
log.Errorf("runPost failed: %+v", err) log.Errorf("runPost failed: %+v", err)
s.failPost(eps)
return return
} }
if err := s.submitPost(ctx, proof); err != nil { if err := s.submitPost(ctx, proof); err != nil {
log.Errorf("submitPost failed: %+v", err) log.Errorf("submitPost failed: %+v", err)
s.failPost(eps)
return return
} }
}() }()
} }

View File

@ -2,6 +2,7 @@ package storage
import ( import (
"context" "context"
"sync"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -29,6 +30,9 @@ type fpostScheduler struct {
// if a post is in progress, this indicates for which ElectionPeriodStart // if a post is in progress, this indicates for which ElectionPeriodStart
activeEPS uint64 activeEPS uint64
abort context.CancelFunc abort context.CancelFunc
failed uint64 // eps
failLk sync.Mutex
} }
func (s *fpostScheduler) run(ctx context.Context) { func (s *fpostScheduler) run(ctx context.Context) {
@ -111,6 +115,13 @@ func (s *fpostScheduler) update(ctx context.Context, new *types.TipSet) error {
return err return err
} }
s.failLk.Lock()
if s.failed > 0 {
s.failed = 0
s.activeEPS = 0
}
s.failLk.Unlock()
if newEPS == s.activeEPS { if newEPS == s.activeEPS {
return nil return nil
} }