improve docs; add DagstoreRecoverShard.
This commit is contained in:
parent
edcd2f34d4
commit
1cc59ade98
@ -171,10 +171,32 @@ type StorageMiner interface {
|
|||||||
// DAG store. Only available on nodes running the markets subsystem.
|
// DAG store. Only available on nodes running the markets subsystem.
|
||||||
DagstoreListShards(ctx context.Context) ([]DagstoreShardInfo, error) //perm:read
|
DagstoreListShards(ctx context.Context) ([]DagstoreShardInfo, error) //perm:read
|
||||||
|
|
||||||
// DagstoreInitializeShard initializes an uninitialized shard by acquiring
|
// DagstoreInitializeShard initializes an uninitialized shard.
|
||||||
// it and releasing it as soon as it's ready.
|
//
|
||||||
|
// Initialization consists of fetching the shard's data (deal payload) from
|
||||||
|
// the storage subsystem, generating an index, and persisting the index
|
||||||
|
// to facilitate later retrievals, and/or to publish to external sources.
|
||||||
|
//
|
||||||
|
// This operation is intended to complement the initial migration. The
|
||||||
|
// migration registers a shard for every unique piece CID, with lazy
|
||||||
|
// initialization. Thus, shards are not initialized immediately to avoid
|
||||||
|
// IO activity competing with proving. Instead, shard are initialized
|
||||||
|
// when first accessed. This method forces the initialization of a shard by
|
||||||
|
// accessing it and immediately releasing it. This is useful to warm up the
|
||||||
|
// cache to facilitate subsequent retrievals, and to generate the indexes
|
||||||
|
// to publish them externally.
|
||||||
|
//
|
||||||
|
// This operation fails if the shard is not in ShardStateNew state.
|
||||||
|
// It blocks until initialization finishes.
|
||||||
DagstoreInitializeShard(ctx context.Context, key string) error //perm:write
|
DagstoreInitializeShard(ctx context.Context, key string) error //perm:write
|
||||||
|
|
||||||
|
// DagstoreRecoverShard attempts to recover a failed shard.
|
||||||
|
//
|
||||||
|
// This operation fails if the shard is not in ShardStateErrored state.
|
||||||
|
// It blocks until recovery finishes. If recovery failed, it returns the
|
||||||
|
// error.
|
||||||
|
DagstoreRecoverShard(ctx context.Context, key string) error //perm:write
|
||||||
|
|
||||||
// DagstoreGC runs garbage collection on the DAG store.
|
// DagstoreGC runs garbage collection on the DAG store.
|
||||||
DagstoreGC(ctx context.Context) ([]DagstoreGCResult, error) //perm:admin
|
DagstoreGC(ctx context.Context) ([]DagstoreGCResult, error) //perm:admin
|
||||||
|
|
||||||
|
@ -609,6 +609,8 @@ type StorageMinerStruct struct {
|
|||||||
|
|
||||||
DagstoreListShards func(p0 context.Context) ([]DagstoreShardInfo, error) `perm:"read"`
|
DagstoreListShards func(p0 context.Context) ([]DagstoreShardInfo, error) `perm:"read"`
|
||||||
|
|
||||||
|
DagstoreRecoverShard func(p0 context.Context, p1 string) error `perm:"write"`
|
||||||
|
|
||||||
DealsConsiderOfflineRetrievalDeals func(p0 context.Context) (bool, error) `perm:"admin"`
|
DealsConsiderOfflineRetrievalDeals func(p0 context.Context) (bool, error) `perm:"admin"`
|
||||||
|
|
||||||
DealsConsiderOfflineStorageDeals func(p0 context.Context) (bool, error) `perm:"admin"`
|
DealsConsiderOfflineStorageDeals func(p0 context.Context) (bool, error) `perm:"admin"`
|
||||||
@ -3608,6 +3610,17 @@ func (s *StorageMinerStub) DagstoreListShards(p0 context.Context) ([]DagstoreSha
|
|||||||
return *new([]DagstoreShardInfo), ErrNotSupported
|
return *new([]DagstoreShardInfo), ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StorageMinerStruct) DagstoreRecoverShard(p0 context.Context, p1 string) error {
|
||||||
|
if s.Internal.DagstoreRecoverShard == nil {
|
||||||
|
return ErrNotSupported
|
||||||
|
}
|
||||||
|
return s.Internal.DagstoreRecoverShard(p0, p1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StorageMinerStub) DagstoreRecoverShard(p0 context.Context, p1 string) error {
|
||||||
|
return ErrNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
func (s *StorageMinerStruct) DealsConsiderOfflineRetrievalDeals(p0 context.Context) (bool, error) {
|
func (s *StorageMinerStruct) DealsConsiderOfflineRetrievalDeals(p0 context.Context) (bool, error) {
|
||||||
if s.Internal.DealsConsiderOfflineRetrievalDeals == nil {
|
if s.Internal.DealsConsiderOfflineRetrievalDeals == nil {
|
||||||
return false, ErrNotSupported
|
return false, ErrNotSupported
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,6 +22,7 @@
|
|||||||
* [DagstoreGC](#DagstoreGC)
|
* [DagstoreGC](#DagstoreGC)
|
||||||
* [DagstoreInitializeShard](#DagstoreInitializeShard)
|
* [DagstoreInitializeShard](#DagstoreInitializeShard)
|
||||||
* [DagstoreListShards](#DagstoreListShards)
|
* [DagstoreListShards](#DagstoreListShards)
|
||||||
|
* [DagstoreRecoverShard](#DagstoreRecoverShard)
|
||||||
* [Deals](#Deals)
|
* [Deals](#Deals)
|
||||||
* [DealsConsiderOfflineRetrievalDeals](#DealsConsiderOfflineRetrievalDeals)
|
* [DealsConsiderOfflineRetrievalDeals](#DealsConsiderOfflineRetrievalDeals)
|
||||||
* [DealsConsiderOfflineStorageDeals](#DealsConsiderOfflineStorageDeals)
|
* [DealsConsiderOfflineStorageDeals](#DealsConsiderOfflineStorageDeals)
|
||||||
@ -363,8 +364,23 @@ Inputs: `null`
|
|||||||
Response: `null`
|
Response: `null`
|
||||||
|
|
||||||
### DagstoreInitializeShard
|
### DagstoreInitializeShard
|
||||||
DagstoreInitializeShard initializes an uninitialized shard by acquiring
|
DagstoreInitializeShard initializes an uninitialized shard.
|
||||||
it and releasing it as soon as it's ready.
|
|
||||||
|
Initialization consists of fetching the shard's data (deal payload) from
|
||||||
|
the storage subsystem, generating an index, and persisting the index
|
||||||
|
to facilitate later retrievals, and/or to publish to external sources.
|
||||||
|
|
||||||
|
This operation is intended to complement the initial migration. The
|
||||||
|
migration registers a shard for every unique piece CID, with lazy
|
||||||
|
initialization. Thus, shards are not initialized immediately to avoid
|
||||||
|
IO activity competing with proving. Instead, shard are initialized
|
||||||
|
when first accessed. This method forces the initialization of a shard by
|
||||||
|
accessing it and immediately releasing it. This is useful to warm up the
|
||||||
|
cache to facilitate subsequent retrievals, and to generate the indexes
|
||||||
|
to publish them externally.
|
||||||
|
|
||||||
|
This operation fails if the shard is not in ShardStateNew state.
|
||||||
|
It blocks until initialization finishes.
|
||||||
|
|
||||||
|
|
||||||
Perms: write
|
Perms: write
|
||||||
@ -389,6 +405,25 @@ Inputs: `null`
|
|||||||
|
|
||||||
Response: `null`
|
Response: `null`
|
||||||
|
|
||||||
|
### DagstoreRecoverShard
|
||||||
|
DagstoreRecoverShard attempts to recover a failed shard.
|
||||||
|
|
||||||
|
This operation fails if the shard is not in ShardStateErrored state.
|
||||||
|
It blocks until recovery finishes. If recovery failed, it returns the
|
||||||
|
error.
|
||||||
|
|
||||||
|
|
||||||
|
Perms: write
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
"string value"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Response: `{}`
|
||||||
|
|
||||||
## Deals
|
## Deals
|
||||||
|
|
||||||
|
|
||||||
|
@ -616,6 +616,36 @@ func (sm *StorageMinerAPI) DagstoreInitializeShard(ctx context.Context, key stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sm *StorageMinerAPI) DagstoreRecoverShard(ctx context.Context, key string) error {
|
||||||
|
if sm.DAGStore == nil {
|
||||||
|
return fmt.Errorf("dagstore not available on this node")
|
||||||
|
}
|
||||||
|
|
||||||
|
k := shard.KeyFromString(key)
|
||||||
|
|
||||||
|
info, err := sm.DAGStore.GetShardInfo(k)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get shard info: %w", err)
|
||||||
|
}
|
||||||
|
if st := info.ShardState; st != dagstore.ShardStateErrored {
|
||||||
|
return fmt.Errorf("cannot recover shard; expected state ShardStateErrored, was: %s", st.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
ch := make(chan dagstore.ShardResult, 1)
|
||||||
|
if err = sm.DAGStore.RecoverShard(ctx, k, ch, dagstore.RecoverOpts{}); err != nil {
|
||||||
|
return fmt.Errorf("failed to recover shard: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var res dagstore.ShardResult
|
||||||
|
select {
|
||||||
|
case res = <-ch:
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.Error
|
||||||
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) DagstoreGC(ctx context.Context) ([]api.DagstoreGCResult, error) {
|
func (sm *StorageMinerAPI) DagstoreGC(ctx context.Context) ([]api.DagstoreGCResult, error) {
|
||||||
if sm.DAGStore == nil {
|
if sm.DAGStore == nil {
|
||||||
return nil, fmt.Errorf("dagstore not available on this node")
|
return nil, fmt.Errorf("dagstore not available on this node")
|
||||||
|
Loading…
Reference in New Issue
Block a user