From a1da31aa0fb66c986208c254ea0b1297fe4c7e8e Mon Sep 17 00:00:00 2001 From: Jeff Jiang Date: Thu, 25 Sep 2025 13:31:20 -0700 Subject: [PATCH] check connections when get_client_slow fails --- sdk/couchbase-core/src/kvclientpool.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sdk/couchbase-core/src/kvclientpool.rs b/sdk/couchbase-core/src/kvclientpool.rs index f6883f86..81b99f83 100644 --- a/sdk/couchbase-core/src/kvclientpool.rs +++ b/sdk/couchbase-core/src/kvclientpool.rs @@ -163,7 +163,19 @@ where } } - self.get_client_slow().await + match self.get_client_slow().await { + Ok(c) => Ok(c), + Err(e) => { + // If we failed to get a client, we should check connections and rebuild the fast map. + // For example, when all clients are terminated by server side sending TCP RST, + // the clients will be evicted from the pool, and therefore, when we try to get a client + // from the pool again, the get will fail, and we need to check connections to create new clients. + debug!("Error getting client from pool: {}", e); + self.check_connections().await; + self.rebuild_fast_map().await; + Err(e) + } + } } pub async fn close(&self) -> Result<()> {