[#1902] engine: Search for the tree IDs in every shard

Iterate over every shard and search for the container's trees. Final result
is a concatenation of shards' results. It is considered that one fixed tree
is placed on one fixed shard but the different trees of a fixed container
could be placed on different shards.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-10-18 18:22:29 +03:00 committed by Pavel Karpy
parent aa37078570
commit 49c38d642d

View file

@ -183,11 +183,10 @@ func (e *StorageEngine) TreeDrop(cid cidSDK.ID, treeID string) error {
// TreeList implements the pilorama.Forest interface.
func (e *StorageEngine) TreeList(cid cidSDK.ID) ([]string, error) {
var ids []string
var err error
var resIDs []string
for _, sh := range e.sortShardsByWeight(cid) {
ids, err = sh.TreeList(cid)
for _, sh := range e.unsortedShards() {
ids, err := sh.TreeList(cid)
if err != nil {
if errors.Is(err, shard.ErrPiloramaDisabled) || errors.Is(err, shard.ErrReadOnlyMode) {
return nil, err
@ -196,11 +195,13 @@ func (e *StorageEngine) TreeList(cid cidSDK.ID) ([]string, error) {
e.reportShardError(sh, "can't perform `TreeList`", err,
zap.Stringer("cid", cid))
// returns as much info about
// trees as possible
continue
}
return ids, nil
resIDs = append(resIDs, ids...)
}
return ids, err
return resIDs, nil
}