Skip to content

Commit 184ea74

Browse files
authored
Merge pull request #29559 from nvartolomei/nv/fix-client-pool-acquire-assert
2 parents efb4def + 1821a38 commit 184ea74

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/v/cloud_storage_clients/client_pool.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,17 @@ ss::future<client_pool::client_lease> client_pool::acquire(
289289
};
290290
// Use 2-random approach. Pick 2 random shards
291291
auto [sid1, sid2] = pick_two_random_shards();
292-
auto cnt1 = co_await container().invoke_on(
293-
sid1, clients_in_use);
294-
// sid1 == sid2 if we have only two shards
295-
auto cnt2 = sid1 == sid2 ? cnt1
296-
: co_await container().invoke_on(
297-
sid2, clients_in_use);
292+
size_t cnt1 = _capacity;
293+
size_t cnt2 = _capacity;
294+
try {
295+
cnt1 = co_await container().invoke_on(sid1, clients_in_use);
296+
cnt2 = sid1 == sid2 ? cnt1
297+
: co_await container().invoke_on(
298+
sid2, clients_in_use);
299+
} catch (const ss::broken_named_semaphore&) {
300+
// Remote shard is shutting down, treat as fully
301+
// utilized so we skip borrowing.
302+
}
298303
auto [sid, cnt] = cnt1 < cnt2 ? std::tie(sid1, cnt1)
299304
: std::tie(sid2, cnt2);
300305
vlog(

0 commit comments

Comments
 (0)