Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement general-purpose pagination functionality in KV API #2168

Open
josiahhaswell opened this issue Jul 6, 2016 · 6 comments
Open

Implement general-purpose pagination functionality in KV API #2168

josiahhaswell opened this issue Jul 6, 2016 · 6 comments
Labels
theme/api Relating to the HTTP API interface theme/kv Issues related to the key value store type/enhancement Proposed improvement or new feature
Milestone

Comments

@josiahhaswell
Copy link

Key hierarchies can grow to be quite large,and this introduces unnecessary and undesirable latencies during retrieval. It would be very nice if the KV API supported pagination. This could be done in a backwards-compatible fashion via query params (possibly something along the lines of)

/v1/kv/sample-key?start=0&end=10

Ordering would also generally be useful; adding

/v1/kv/sample-key?start=0&end=10&order=desc|asc

would sort the results by the lexicographical ordering of the keys under sample-key.

This could also be integrated consistently with recurse by performing a depth-first traversal of the keys in range [start, end] under the provided sort criterion and returning that set.

Thanks!
Josiah

@slackpad slackpad added type/enhancement Proposed improvement or new feature post-0.9 labels May 15, 2017
@slackpad slackpad added the theme/api Relating to the HTTP API interface label May 25, 2017
@slackpad slackpad added this to the Unplanned milestone Jan 5, 2018
@slackpad slackpad removed the post-0.9 label Jan 5, 2018
@MatthiasGrandl
Copy link

Any news on this? It seems incredible that such a feature does not exist while filtering does.

@jkirschner-hashicorp jkirschner-hashicorp added the theme/kv Issues related to the key value store label Aug 30, 2021
@vnktram
Copy link

vnktram commented Oct 13, 2021

Can I pick this one?

@jkirschner-hashicorp
Copy link
Contributor

Hi @vnktram,

Thanks for volunteering to contribute to Consul! Give me a bit of time to seek the Consul team's perspective on this first - I'll update you next week.

@dnephin
Copy link
Contributor

dnephin commented Oct 19, 2021

Thank you for your interest in implementing this feature! I think before we review any implementation it would be good to outline how the problem will be solved. Implementing pagination in Consul is more difficult than it might be in other systems.

One of the challenges is that Consul does not use sequential IDs. The KV entries are indexed by the key name. The keys could change between requests, which could lead to duplicate or missing keys in the response. One option for solving this problem might be to use the CreateIndex as the ID when querying with pagination. That should prevent updates to existing keys from changing the results.

Another challenge is how to query the state store. We currently do not index by CreateIndex, and we do not use range queries (as far as I know). So we would need to add an index to the state store. We would also need to use https://pkg.go.dev/github.com/hashicorp/go-memdb#Txn.LowerBound to query the appropriate range of values (instead of Txn.Get).

If you are interested in picking up this issue, we'd encourage you to first write up a design for the solution (either as a comment in this issue, or as a new issue). The design should cover how the above two challenges will be addressed, and also detail how the new HTTP API query parameters will work, and if there is any interaction with existing API query parameters. That write up will make it much easier for us review any pull requests that implement this feature.

@vnktram
Copy link

vnktram commented Oct 25, 2021

@dnephin Ack. Let me document the proposed design with your suggestions in mind and share it shortly.

@mstrYoda
Copy link
Contributor

Hi all, what is the current status of this issue?

@vnktram @dnephin ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/api Relating to the HTTP API interface theme/kv Issues related to the key value store type/enhancement Proposed improvement or new feature
Projects
None yet
Development

No branches or pull requests

7 participants