-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add UpdatesOnly query option to fetch data for only changed keys #22108
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
Add UpdatesOnly query option to fetch data for only changed keys #22108
Conversation
e9953d7
to
87a7836
Compare
As mentioned long ago (and roughly outlined) in hashicorp#2791, a limitation on blocking queries is that all K/V entries matching that prefix are returned, even though only 1 key may have changed. This diff adds a new `UpdatesOnly` option, that when set, introduces server-side filtering to remove all keys/entries (from a `Keys()` or `List()` query) that have an old `ModifyIndex`. It uses `MinQueryIndex` as the threshold here, which follows the effective serialization/deserialization chain: `WaitIndex` --> `index` --> `MinQueryIndex`. - `WaitIndex` being the client-side parameter, determining the index the "client" waits for on a blocking query - `index` being the serialized HTTP query parameter representing the `WaitIndex` - `MinQueryIndex` being the server-side struct (deserialized result of `index`) While we (potentially?) wait for the streaming backend: https://developer.hashicorp.com/consul/api-docs/features/blocking#streaming-backend to be implemented for KV endpoints, this can be a good stop-gap solution to enable in-memory, incremental scans or queries over a prefix.
87a7836
to
c9997a8
Compare
reply.QueryMeta.ResultsFilteredByACLs = total != len(ent) | ||
total := len(entries) | ||
entries = FilterDirEnt(authz, entries) | ||
reply.QueryMeta.ResultsFilteredByACLs = total != len(entries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open q: similar to how we hydrate ResultsFilteredByACLs
in the QueryMeta introduced by #11569, does it make sense to do the same thing here for filtering by query index?
This pull request has been automatically flagged for inactivity because it has not been acted upon in the last 60 days. It will be closed if no new activity occurs in the next 30 days. Please feel free to re-open to resurrect the change if you feel this has happened by mistake. Thank you for your contributions. |
Closing due to inactivity. If you feel this was a mistake or you wish to re-open at any time in the future, please leave a comment and it will be re-surfaced for the maintainers to review. |
Description
As mentioned long ago (and roughly outlined) in #2791, a limitation on blocking queries is that all K/V entries matching that prefix are returned, even though only 1 key may have changed. This diff adds a new
UpdatesOnly
option, that when set, introduces server-side filtering to remove all keys/entries (from aKeys()
orList()
query) that have an oldModifyIndex
.It uses
MinQueryIndex
as the threshold here, which follows the effective serialization/deserialization chain:WaitIndex
-->index
-->MinQueryIndex
.WaitIndex
being the client-side parameter, determining the index the "client" waits for on a blocking queryindex
being the serialized HTTP query parameter representing theWaitIndex
MinQueryIndex
being the server-side struct (deserialized result ofindex
)While we (potentially?) wait for the streaming backend: https://developer.hashicorp.com/consul/api-docs/features/blocking#streaming-backend to be implemented for KV endpoints, this can be a good stop-gap solution to enable in-memory, incremental scans or queries over a prefix.
Testing & Reproduction steps
minQueryIndex
passed down the state layer to be 0 (no filtering)state/kvs_test.go
to illustrate the filtering based onModifyIndex
Links
Original GH issue: #2791
PR Checklist