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
default policy: Rack awareness without token awareness #777
default policy: Rack awareness without token awareness #777
Conversation
9d08507
to
fb225fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@havaker please take a look as well
@@ -170,8 +170,22 @@ or refrain from preferring datacenters (which may ban all other datacenters, if | |||
// some alive local node. | |||
// If there was no preferred datacenter specified, all nodes are treated as local. | |||
let nodes = self.preferred_node_set(cluster); | |||
let picked = Self::pick_node(nodes, &self.pick_predicate); | |||
if let Some(alive_local) = picked { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token_with_strategy.is_some()
and token_with_strategy_is_none()
paths look very similar. Perhaps we could unify them somehow? Not necessarily here, just food for thought for future improvements.
fb225fc
to
5bf2e55
Compare
The predicate is more convenient for use in this form, because methods such as `filter()` expect predicates to take values by reference. It makes implementation in the following commit more elegant. However, it unfortunately brings a breaking change.
Until now, the default policy respected rack preference only when it came to replicas. Considering non-token-aware queries (e.g. unprepared statements), they would never prioritize the preferred rack. Now, local rack nodes are always preferred before other nodes, both in `pick()` and in `fallback()`. Tests and docs are adjusted for this behaviour. One new test is added for the case when no token is provided and a rack is preferred.
As rack awareness now prefers not only local-rack replicas over other replicas, but also local-rack nodes over other nodes, the name of `ReplicaLocationPreference` is changed to `NodeLocationPreference` and similarly for `ReplicaLocationCriteria`.
5bf2e55
to
0fca0db
Compare
v2:
|
Until now, the default policy respected rack preference only when it came to replicas.
Considering non-token-aware queries (e.g. unprepared statements), they would never prioritize the preferred rack.
Now, local rack nodes are always preferred before other nodes, both in
pick()
and infallback()
.Existing tests adjusted for new behaviour.
The PR contains breaking changes, as it slightly changes signature of
ReplicaSet::choose_filtered()
(note the reference added).Pre-review checklist
[ ] I have provided docstrings for the public items that I want to introduce../docs/source/
.[ ] I added appropriateFixes:
annotations to PR description.