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

prevKV not being returned if the previous KV was compacted is suprising behavior #10681

Open
jpbetz opened this issue Apr 26, 2019 · 6 comments

Comments

@jpbetz
Copy link
Contributor

jpbetz commented Apr 26, 2019

See kubernetes/kubernetes#76624

For delete watch event, in particular, I'm guessing the conditions for this to happen would be something like:

1: put "/x" -> "value" (revision=1)
2. create watch "/x"
3. delete "/x" (revision=2)
4. compaction
5. "/x deleted" watch event sent

Because if the compaction happened before (3) or after (5), the prevKV would be included in the "/x deleted" watch event (revision 1 of "/x" can't be compacted until after the delete). I'm concerned this is a rare enough situation that clients that make use of prevKV are unlikely to see it in development and even more unlikely to write code to defend against it until it breaks in production.

One option would be to terminate the watch with ErrCompacted rather than returning a watch event with a missing prevKV. Clients would need to re-establish the watch if they get the ErrCompacted error, but they need to be written to be able to do that already. Only watches with WithPrevKV() enabled would be impacted.

Another would be to modify compaction to retain both the latest and the previous of each KV. This would 2x minimum disk space in the worst case.

@jpbetz
Copy link
Contributor Author

jpbetz commented Apr 26, 2019

cc @liggitt @jingyih @xiang90

@stale
Copy link

stale bot commented Apr 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 7, 2020
@liggitt
Copy link
Contributor

liggitt commented Apr 7, 2020

Do watches ever end with a compacted error today?

@stale stale bot removed the stale label Apr 7, 2020
@xiang90
Copy link
Contributor

xiang90 commented Apr 7, 2020

@liggitt

It should return errCompacted.

@stale
Copy link

stale bot commented Jul 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 6, 2020
@stale stale bot closed this as completed Jul 27, 2020
@serathius
Copy link
Member

Would like to revisit this as part of Kubernetes-etcd contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants