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

KV put should return ModifyIndex to allow for optimistic locking #14258

Open
fgoepel opened this issue Aug 18, 2022 · 0 comments
Open

KV put should return ModifyIndex to allow for optimistic locking #14258

fgoepel opened this issue Aug 18, 2022 · 0 comments
Labels
theme/kv Issues related to the key value store type/enhancement Proposed improvement or new feature

Comments

@fgoepel
Copy link

fgoepel commented Aug 18, 2022

Consul KVs seem like a good fit for counters that need to be sequential cluster wide. This can be implemented using PUT with the "cas" option set to the last known values ModifyIndex when updating the counter value. Unfortunately this seems to always require re-fetching the current value to get access to the current ModifyIndex, even if no other updates have occurred, as there is apparently no way for the successful PUT operation to return the new ModifyIndex and it's not reliably predictable either.

If the PUT operation were to return the new ModifyIndex, either as JSON or as an additional header, it would be possible to optimistically update the value without refetching, in cases where concurrent updates are rare. I doubt you'll be eager to change the return value of PUT, as it would break existing code, but adding an additional "X-Consul-ModifyIndex" should not be disruptive. This header could also be added for GETs, then the "raw" option could be used in this case and Base64+JSON coding of the value could be avoided. (You may want to add the other fields from the JSON response as headers as well for consistency.)

@jkirschner-hashicorp jkirschner-hashicorp added type/enhancement Proposed improvement or new feature theme/kv Issues related to the key value store labels Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants