morph: Fix batch size in TraverseIterator() #1000

Merged
fyrchik merged 2 commits from fyrchik/frostfs-node:fix-iterator into master 2024-02-23 06:24:42 +00:00
2 changed files with 9 additions and 4 deletions

View file

@ -177,12 +177,12 @@ func dumpCustomZoneHashes(cmd *cobra.Command, nnsHash util.Uint160, zone string,
_ = inv.TerminateSession(sessionID)
}()
items, err := inv.TraverseIterator(sessionID, &iter, nnsMaxTokens)
items, err := inv.TraverseIterator(sessionID, &iter, 0)
for err == nil && len(items) != 0 {
for i := range items {
processItem(items[i])
}
items, err = inv.TraverseIterator(sessionID, &iter, nnsMaxTokens)
items, err = inv.TraverseIterator(sessionID, &iter, 0)
}
if err != nil {
return fmt.Errorf("error during NNS domains iteration: %w", err)

View file

@ -260,8 +260,13 @@ func (c *Client) TestInvokeIterator(cb func(stackitem.Item) error, batchSize int
_ = c.rpcActor.TerminateSession(sid)
}()
// Batch size for TraverseIterator() can restricted on the server-side.
traverseBatchSize := batchSize
if invoker.DefaultIteratorResultItems < traverseBatchSize {
traverseBatchSize = invoker.DefaultIteratorResultItems
}
for {
items, err := c.rpcActor.TraverseIterator(sid, &r, batchSize)
items, err := c.rpcActor.TraverseIterator(sid, &r, traverseBatchSize)
if err != nil {
return err
}
@ -271,7 +276,7 @@ func (c *Client) TestInvokeIterator(cb func(stackitem.Item) error, batchSize int
return err
}
}
if len(items) < batchSize {
if len(items) < traverseBatchSize {
break
}
}