Skip to content

Range requests with limit ignore limit when sorting by key ascending #20745

@jprieto-temporal

Description

@jprieto-temporal

Bug report criteria

What happened?

When performing a range request with a limit and sorting by key in ascending order, etcd currently ignores the limit and fetches all matching keys from the backend, then truncates them in memory. This causes unnecessary performance overhead and memory usage.

What did you expect to happen?

The query result is correct, but it would be better if the server retained the limit requested by the user.

How can we reproduce it (as minimally and precisely as possible)?

Execute a query with sort order set to ascending by key. You can't directly observe this bug, but the internal behavior of the server when executing this query is inefficient.

Anything else we need to know?

No response

Etcd version (please run commands below)

$ etcd --version
etcd Version: 3.5.17
Git SHA: 507c0de87
Go Version: go1.23.3
Go OS/Arch: darwin/arm64


$ etcdctl version

etcdctl version: 3.5.17
API version: 3.5

This behavior is also present in 3.6

Etcd configuration (command line flags or environment variables)

paste your configuration here

Etcd debug information (please run commands below, feel free to obfuscate the IP address or FQDN in the output)

$ etcdctl member list -w table
# paste output here

$ etcdctl --endpoints=<member list> endpoint status -w table
# paste output here

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions