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

topo support stale reads for consul #561

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

demmer
Copy link
Collaborator

@demmer demmer commented Nov 15, 2024

Description

Add optional support for AllowStale reads in the consul topo when polling for tablets in discovery.

Consul supports relaxed consistency on K/V reads as described in https://developer.hashicorp.com/consul/api-docs/features/consistency.

In particular there is a performant option for stale reads that allow lagged replies from a replica:

stale - Consul DNS queries use stale mode by default. This mode allows any server to handle the read regardless of whether it is the leader. The trade-off is very fast and scalable reads with a higher likelihood of stale values. Results are generally consistent to within 50 milliseconds of the leader, though there is no upper limit on this staleness. Since this mode allows reads without a leader, a cluster that is unavailable (no quorum) can still respond to queries.

None of the Vitess K/V options utilize this mode however, which means that all operations must go to the primary leader.

At the same time, the discovery TopologyWatcher as used by vtgate and other components repeatedly polls the tablet list to discover new tablets that have been added to the registry. As such, it can tolerate stale reads on a given request since it will turn around and re-request in the future.

To make this more efficient, this PR plumbs through an option so that this polling workloads sets the more relaxed AllowStale consistency option on the KV read, which should improve consul topo service performance.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on the CI
  • Documentation was added or is not required

Deployment Notes

For the TopologyWatcher which repeatedly lists all tablets from the topo, pass
in a polling option into the service List method as a hint to implementations
that support increased performance with relaxed consistency.

Signed-off-by: Michael Demmer <[email protected]>
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 this pull request may close these issues.

1 participant