Skip to content

Commit

Permalink
fix(share/eds): recover Shards immediately
Browse files Browse the repository at this point in the history
Discovered after looking at CarStore sources(https://github.com/filecoin-saturn/L2-node/blob/f5c5ca0cd8cab27d83424e7a77943f900a4d4105/carstore/carstore.go#L177)
I think it should aid long startup times by recoviring shards immediately, rather than on restart/startup only
  • Loading branch information
Wondertan committed May 2, 2023
1 parent 11fea99 commit 63b9968
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions share/eds/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const (
indexPath = "/index/"
transientsPath = "/transients/"

defaultGCInterval = time.Hour
defaultGCInterval = time.Hour
maxRecoverAttempts = 1
)

var ErrNotFound = errors.New("eds not found in store")
Expand All @@ -46,8 +47,9 @@ var ErrNotFound = errors.New("eds not found in store")
type Store struct {
cancel context.CancelFunc

dgstr *dagstore.DAGStore
mounts *mount.Registry
dgstr *dagstore.DAGStore
mounts *mount.Registry
dgstrFailureCh chan dagstore.ShardResult

cache *blockstoreCache
bs bstore.Blockstore
Expand Down Expand Up @@ -79,6 +81,7 @@ func NewStore(basepath string, ds datastore.Batching) (*Store, error) {
return nil, fmt.Errorf("failed to create index repository: %w", err)
}

failureCh := make(chan dagstore.ShardResult, 1)
invertedRepo := newSimpleInvertedIndex(ds)
dagStore, err := dagstore.NewDAGStore(
dagstore.Config{
Expand All @@ -87,6 +90,7 @@ func NewStore(basepath string, ds datastore.Batching) (*Store, error) {
Datastore: ds,
MountRegistry: r,
TopLevelIndex: invertedRepo,
FailureCh: failureCh,
},
)
if err != nil {
Expand Down Expand Up @@ -116,10 +120,12 @@ func (s *Store) Start(ctx context.Context) error {
if err != nil {
return err
}

// start Store only if DagStore succeeds
ctx, cancel := context.WithCancel(context.Background())
s.cancel = cancel
go s.gc(ctx)
go dagstore.RecoverImmediately(ctx, s.dgstr, s.dgstrFailureCh, 1, nil)
return nil
}

Expand Down

0 comments on commit 63b9968

Please sign in to comment.