-
Notifications
You must be signed in to change notification settings - Fork 550
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
Async Cluster: Connection is created on each request #1025
Comments
Sounds like you reach this line, where the connection is created but not saved - redis-rs/redis/src/cluster_async/mod.rs Line 873 in a980a5f
I believe that the solution is something like match connect_and_check::<C>(&addr, core.cluster_params.clone()).await {
Ok(conn) => {
let conn_clone = conn.clone();
core.conn_lock
.write()
.await
.0
.insert(addr.clone(), async { conn_clone }.boxed().shared());
Some((addr, conn))
}
Err(_) => None,
} but I can't recreate this situation in a test, so can't verify it. |
Just tested your fix: it works for me. Without it most of the time I get into the situation described above, with it never. I am not sure how to approach a test case for it. I reproduce it by having a connection with specific settings (both timeouts 400ms and retries set to 1). This connection does a request each 400ms. I now have a cluster with one node, where I execute Not really something that lends itself to a reliable test case 🤷 |
Ok, different take - does this solve your issue? IMO both fixes are correct and relevant, but I want to be sure that what I think will work actually will work :) |
Managed to write the world's most artificial tests for the first fix, hurrah! |
Yes it does 😊 I am especially enthusiastic about this one, because it also resolves the issue of panics when I use long Those two fixes are great, thank you! |
Fixed in release 0.25.0 |
I am playing around with the async cluster timeouts, and ended up in a strange situation: for each redis request I am triggering,
redis-rs
will callconnect_and_check
and create a new connection.Initially I got in this situation by triggering a timeout and the following reconnection also lead to a timeout. My request is a simple
GET
.What I am observing is that in
get_connection
the branch withconnect_and_check
is taken and succeeds. But during the next request the same branch is taken, because the connection is stillNone
.Is it possible, that the connection, that is created in
connect_and_check
inget_connection
needs to be stored back into theconn_lock
?My text is just wild guessing, but the issue is quite reproducible for me, so I can dig deeper if needed.
The text was updated successfully, but these errors were encountered: