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

Reset WaitIndex when a smaller WaitIndex is returned #26

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

fho
Copy link
Contributor

@fho fho commented Feb 15, 2023

According to the Consul doc1, resolvers must handle the case that Consul returns a WaitIndex that was lower then the requested one, by doing another query with a WaitIndex of 0.
If this is not done, updates can be missed.

Quote from the Documentation1
Reset the index if it goes backwards. While indexes in general are
monotonically increasing(i.e. they should only ever increase as time passes),
there are several real-world scenarios in which they can go backwards for a
given query. Implementations must check to see if a returned index is lower
than the previous value, and if it is, should reset index to 0 - effectively
restarting their blocking loop. Failure to do so may cause the client to miss
future updates for an unbounded time, or to use an invalid index value that
causes no blocking and increases load on the servers. Cases where this can
occur include: If a raft snapshot is restored on the servers with older
version of the data. KV list operations where an item with the highest index
is removed. A Consul upgrade changes the way watches work to optimize them
with more granular indexes.


follow-up issue to add a unit-test: #27

Footnotes

  1. https://developer.hashicorp.com/consul/api-docs/features/blocking 2

According to the Consul doc[^1], resolvers must handle the case that Consul
returns a WaitIndex that was lower then the requested one, by doing another
query with a WaitIndex of 0.
If this is not done, updates can be missed.

Quote from the Documentation[^1]
  Reset the index if it goes backwards. While indexes in general are
  monotonically increasing(i.e. they should only ever increase as time passes),
  there are several real-world scenarios in which they can go backwards for a
  given query. Implementations must check to see if a returned index is lower
  than the previous value, and if it is, should reset index to 0 - effectively
  restarting their blocking loop. Failure to do so may cause the client to miss
  future updates for an unbounded time, or to use an invalid index value that
  causes no blocking and increases load on the servers. Cases where this can
  occur include: If a raft snapshot is restored on the servers with older
  version of the data. KV list operations where an item with the highest index
  is removed. A Consul upgrade changes the way watches work to optimize them
  with more granular indexes.

[^1]: https://developer.hashicorp.com/consul/api-docs/features/blocking
@fho fho self-assigned this Feb 15, 2023
@fho fho added the enhancement New feature or request label Feb 15, 2023
@fho fho added this to the v1.4.0 milestone Feb 15, 2023
@fho fho requested a review from FranciscoKurpiel February 15, 2023 18:07
@fho fho added bug Something isn't working and removed enhancement New feature or request labels Feb 15, 2023
@fho fho merged commit 9cb89bd into master Feb 16, 2023
@fho fho deleted the resolver_backwards_waitidx branch February 16, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants