Skip to content

Commit 738bd09

Browse files
committed
transport: use connect_timeout for use_keyspace
Our use_keyspace() utility may hang if any of the nodes are not available. Since the default TCP timeout is rather long (10 minutes on most systems), let's instead use the existing connection timeout as the timeout value.
1 parent 5a9259a commit 738bd09

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scylla/src/transport/connection_pool.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ impl PoolRefiller {
10171017
let mut conns = self.conns.clone();
10181018
let keyspace_name = keyspace_name.clone();
10191019
let address = self.address;
1020+
let connect_timeout = self.pool_config.connection_config.connect_timeout;
10201021

10211022
let fut = async move {
10221023
let mut use_keyspace_futures = Vec::new();
@@ -1032,8 +1033,12 @@ impl PoolRefiller {
10321033
return Ok(());
10331034
}
10341035

1035-
let use_keyspace_results: Vec<Result<(), QueryError>> =
1036-
futures::future::join_all(use_keyspace_futures).await;
1036+
let use_keyspace_results: Vec<Result<(), QueryError>> = tokio::time::timeout(
1037+
connect_timeout,
1038+
futures::future::join_all(use_keyspace_futures),
1039+
)
1040+
.await
1041+
.map_err(|_| QueryError::TimeoutError)?;
10371042

10381043
// If there was at least one Ok and the rest were IoErrors we can return Ok
10391044
// keyspace name is correct and will be used on broken connection on the next reconnect

0 commit comments

Comments
 (0)