-
Notifications
You must be signed in to change notification settings - Fork 16
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
Added periodic topology checks #51
Conversation
b5e0304
to
3b4bbdd
Compare
f18ce76
to
8ab226b
Compare
b4b07f9
to
5b27f1f
Compare
@nihohit ready for review |
3aabf2d
to
e00e610
Compare
@nihohit this time for real, ready for review:) |
@barshaul benchmarks? |
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.
round
redis/src/cluster_async/mod.rs
Outdated
#[cfg(all(not(feature = "tokio-comp"), feature = "async-std-comp"))] | ||
async_std::task::sleep(interval_duration).await; | ||
let read_guard = inner.conn_lock.read().await; | ||
if read_guard.get_current_topology_hash().is_none() { |
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.
why do that? sounds like this is exactly the situation where we want a topology refresh.
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.
Actually, it cannot be None. When a new ClusterConnInner is being created, before we start the periodic checks we do refresh slots. If refresh slots failed it will fail the ClusterConnInner creation, otherwise it has to set the topology hash with Some(val).
Do you think it's better if i'll remove the Option and initialize it with 0?
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.
sure, use 0.
Ok(()) | ||
.await; | ||
if topology_check_res.is_ok() && topology_check_res.unwrap() { | ||
let _ = Self::refresh_slots_with_retries(inner.clone()).await; |
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.
why trigger a new process and querying more nodes, instead of using the new topology result?
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 new topology result is based on log2n nodes. We cannot know at this stage if their view is accurate - if this small number of nodes have the most common view across the cluster nodes.
I can optimize it that if it's a single node cluster we'll use this view, but i'm not sure if it's really necessary. WDYT
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.
IMO even using a smaller sample is safe enough here, but if you're ok with delaying the slot refresh by another network round trip, it's fine.
48308b1
to
2652921
Compare
@nihohit round |
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.
fsm
redis/src/cluster_async/mod.rs
Outdated
.await?; | ||
Ok(()) | ||
.await; | ||
if topology_check_res.is_ok() && topology_check_res.unwrap() { |
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.
sorry, if let Ok(true) = res {
2652921
to
40564f0
Compare
This PR adds an optional periodic topology checks to the async cluster client.
<style> </style>The current periodic check use the user's connections. On the next PR I will add management connections that will be used for this checks.