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"
|
"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
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user