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

Watches which begin at revision 0 actually start later #11496

Closed
aphyr opened this issue Jan 6, 2020 · 4 comments · Fixed by #11559
Closed

Watches which begin at revision 0 actually start later #11496

aphyr opened this issue Jan 6, 2020 · 4 comments · Fixed by #11559

Comments

@aphyr
Copy link

@aphyr aphyr commented Jan 6, 2020

This might be a bug, but I think it could also be undocumented or intended behavior in 3.4.3.

etcd's data model docs and
glossary say that revisions are monotonically increasing 64-bit integers, but don't specify what the first revision in the history is. If users want to watch all changes to a key from the beginning of time, they might begin a watch with revision 0. However, such a watch returns changes not from revision 0 (if that exists) or 1, but from some later revision--possibly the current revision on whatever node the client's talking to? Beginning with revision 1 does appear to capture all changes.

I suggest that etcd document the initial behavior around revisions: what is the first revision in etcd? Is the empty, initial state revision 0, and later revisions 1, 2, 3, ...? If so, should passing revision 0 for a watch return all changes? Or, if 0 is intended to be a special value in the watch API, meaning "the current revision", could this behavior be documented?

@spzala
Copy link
Member

@spzala spzala commented Jan 7, 2020

I see this behavior and that current revision is incremented by 1 when revision 0 is used (same as not specifying/default, which watches future changes) https://github.com/etcd-io/etcd/blob/master/etcdserver/api/v3rpc/watch.go#L271
@xiang90 @gyuho documenting it as @aphyr suggested should be good to address this issue? Thanks!

@jingyih
Copy link
Member

@jingyih jingyih commented Jan 14, 2020

In proto3, default value (which is 0 in this case) can indicate non-presence or presence and that the value was set to the default. So the watch starts with current store revision. Improving doc sounds good to me.

@xiang90
Copy link
Contributor

@xiang90 xiang90 commented Jan 14, 2020

@jingyih can you send a PR to improve the documentation? thanks!

@aphyr
Copy link
Author

@aphyr aphyr commented Jan 28, 2020

You may still want to document that explicitly passing 0 for watches means "the current server revision, plus one".

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

Successfully merging a pull request may close this issue.

4 participants