Merge pull request #797 from filecoin-project/fix/fpost-restart
Restart fPoSt after fail
This commit is contained in:
commit
51afeb0588
@ -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
|
||||
}
|
||||
|
||||
}()
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user