GetSubTree with sort order does not return more than 1000 elements with the same FileName attribute #1642

Open
opened 2025-02-11 15:13:08 +00:00 by alexvanin · 0 comments
Owner

Expected Behavior

GetSubTree RPC returns all available nodes if they have non-empty FileName attribute

Current Behavior

GetSubTree RPC returns up to 1000 nodes for nodes with the same non-empty FileName attribute.

Steps to Reproduce (for bugs)

  1. Create container
  2. Call AddByPath more than 1000 times with the same FileName attribute
  3. Try to list all these nodes with GetSubTree
import (
        "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
        "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree"
)
...
poolInitParams := tree.InitParameters{}
poolInitParams.AddNode(pool.NewNodeParam(1, "127.0.0.1:8080", 1))
poolInitParams.SetKey(key)

ctx := context.Background()

cli, err := tree.NewPool(poolInitParams)
require.NoError(t, err)
err = cli.Dial(ctx)
require.NoError(t, err)

var cnrID cid.ID
err = cnrID.DecodeString("8BNKcqJ1aFmQqUukCtMoUYsxMSXE1jkAK6EZbesvv2cY")
require.NoError(t, err)

const treeID = "versions"
const n = 2000

for i := 0; i < n; i++ {
        path := []string{"dir"}

        _, err = cli.AddNodeByPath(ctx, tree.AddNodeByPathParams{
                CID:    cnrID,  
                TreeID: treeID, 
                Path:   path,   
                Meta: map[string]string{
                        "FileName": "same-version",
                        "id":       fmt.Sprintf("%d", i),
                },      
        })      
        require.NoError(t, err)
}

rdr, err := cli.GetSubTree(ctx, tree.GetSubTreeParams{
        CID:    cnrID,  
        TreeID: treeID, 
        Order:  tree.AscendingOrder,
})
require.NoError(t, err)

elements, err := rdr.ReadAll()
require.NoError(t, err)

require.Len(t, elements, n+2)

Context

S3 gateway may store multiple versions of the same object, so these tree node all have the same FilePath attribute but different object id in the meta. When gate tries to list all available versions, it does not show more than 1000 versions of the same object. In the meantime, it works as expected when FileName attribute is different.

We've already met this issue with 1000 objects while listing multipart data: TrueCloudLab/frostfs-s3-gw#472. Multipart tree nodes does not have FileName attribute so we had to disable sorting to return more than 1000 objects. However this is not the case now.

Regression

Seems like no.

Your Environment

frostfs-node v0.42.18
frostfs-noed v0.44.8

## Expected Behavior GetSubTree RPC returns all available nodes if they have non-empty `FileName` attribute ## Current Behavior GetSubTree RPC returns up to 1000 nodes for nodes with the same non-empty `FileName` attribute. ## Steps to Reproduce (for bugs) 1. Create container 2. Call AddByPath more than 1000 times with the same FileName attribute 3. Try to list all these nodes with GetSubTree ```go import ( "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree" ) ... poolInitParams := tree.InitParameters{} poolInitParams.AddNode(pool.NewNodeParam(1, "127.0.0.1:8080", 1)) poolInitParams.SetKey(key) ctx := context.Background() cli, err := tree.NewPool(poolInitParams) require.NoError(t, err) err = cli.Dial(ctx) require.NoError(t, err) var cnrID cid.ID err = cnrID.DecodeString("8BNKcqJ1aFmQqUukCtMoUYsxMSXE1jkAK6EZbesvv2cY") require.NoError(t, err) const treeID = "versions" const n = 2000 for i := 0; i < n; i++ { path := []string{"dir"} _, err = cli.AddNodeByPath(ctx, tree.AddNodeByPathParams{ CID: cnrID, TreeID: treeID, Path: path, Meta: map[string]string{ "FileName": "same-version", "id": fmt.Sprintf("%d", i), }, }) require.NoError(t, err) } rdr, err := cli.GetSubTree(ctx, tree.GetSubTreeParams{ CID: cnrID, TreeID: treeID, Order: tree.AscendingOrder, }) require.NoError(t, err) elements, err := rdr.ReadAll() require.NoError(t, err) require.Len(t, elements, n+2) ``` ## Context S3 gateway may store multiple versions of the same object, so these tree node all have the same FilePath attribute but different object id in the meta. When gate tries to list all available versions, it does not show more than 1000 versions of the same object. In the meantime, it works as expected when FileName attribute is different. We've already met this issue with 1000 objects while listing multipart data: https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/pulls/472. Multipart tree nodes does not have `FileName` attribute so we had to disable sorting to return more than 1000 objects. However this is not the case now. ## Regression Seems like no. ## Your Environment frostfs-node v0.42.18 frostfs-noed v0.44.8
alexvanin added the
bug
triage
labels 2025-02-11 15:13:08 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1642
No description provided.