You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ya...@apache.org on 2023/01/06 02:32:46 UTC
[doris] branch branch-1.2-lts updated: [enhancement](frontendservice) add retry when create connection to frontend service (#15635)
This is an automated email from the ASF dual-hosted git repository.
yangzhg pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new 63e1c4594e [enhancement](frontendservice) add retry when create connection to frontend service (#15635)
63e1c4594e is described below
commit 63e1c4594e76604cc5e9eb25d100e3a4e99bed2d
Author: Zhengguo Yang <ya...@gmail.com>
AuthorDate: Fri Jan 6 09:15:08 2023 +0800
[enhancement](frontendservice) add retry when create connection to frontend service (#15635)
---
be/src/runtime/client_cache.h | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/be/src/runtime/client_cache.h b/be/src/runtime/client_cache.h
index cbef1631cc..a8d1f47b33 100644
--- a/be/src/runtime/client_cache.h
+++ b/be/src/runtime/client_cache.h
@@ -149,22 +149,25 @@ template <class T>
class ClientConnection {
public:
ClientConnection(ClientCache<T>* client_cache, const TNetworkAddress& address, Status* status)
- : _client_cache(client_cache), _client(nullptr) {
- *status = _client_cache->get_client(address, &_client, 0);
-
- if (status->ok()) {
- DCHECK(_client != nullptr);
- }
- }
+ : ClientConnection(client_cache, address, 0, status, 3) {}
ClientConnection(ClientCache<T>* client_cache, const TNetworkAddress& address, int timeout_ms,
- Status* status)
+ Status* status, int max_retries = 3)
: _client_cache(client_cache), _client(nullptr) {
- *status = _client_cache->get_client(address, &_client, timeout_ms);
-
- if (status->ok()) {
- DCHECK(_client != nullptr);
- }
+ int num_retries = 0;
+ do {
+ *status = _client_cache->get_client(address, &_client, timeout_ms);
+ if (status->ok()) {
+ DCHECK(_client != nullptr);
+ break;
+ }
+ if (num_retries++ < max_retries) {
+ // exponential backoff retry with starting delay of 500ms
+ usleep(500000 * (1 << num_retries));
+ LOG(INFO) << "Failed to get client from cache: " << status->to_string()
+ << ", retrying[" << num_retries << "]...";
+ }
+ } while (num_retries < max_retries);
}
~ClientConnection() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org