This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 531097d9eba [fix](conn-pool) Avoid some invalid connections returned 
to pool (#41597)
531097d9eba is described below

commit 531097d9eba10ee037a92b89d9bef7f21234e369
Author: Siyang Tang <[email protected]>
AuthorDate: Thu Oct 10 11:14:42 2024 +0800

    [fix](conn-pool) Avoid some invalid connections returned to pool (#41597)
    
    ## Proposed changes
    
    Some invalidated connections will be returned to connection pool when
    exception. Fix this incorrection.
---
 .../doris/cloud/catalog/CloudTabletRebalancer.java     | 18 ++++++++++++++----
 .../org/apache/doris/common/util/ProfileManager.java   | 11 ++++++++---
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
index dccce2c3dcb..78947afdb11 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java
@@ -727,6 +727,7 @@ public class CloudTabletRebalancer extends MasterDaemon {
         TNetworkAddress address = null;
         Backend srcBackend = cloudSystemInfoService.getBackend(srcBe);
         Backend destBackend = cloudSystemInfoService.getBackend(destBe);
+        boolean ok = true;
         try {
             address = new TNetworkAddress(destBackend.getHost(), 
destBackend.getBePort());
             client = ClientPool.backendPool.borrowObject(address);
@@ -743,10 +744,14 @@ public class CloudTabletRebalancer extends MasterDaemon {
             }
         } catch (Exception e) {
             LOG.warn("send pre heating rpc error. backend[{}]", 
destBackend.getId(), e);
-            ClientPool.backendPool.invalidateObject(address, client);
+            ok = false;
             throw e;
         } finally {
-            ClientPool.backendPool.returnObject(address, client);
+            if (ok) {
+                ClientPool.backendPool.returnObject(address, client);
+            } else {
+                ClientPool.backendPool.invalidateObject(address, client);
+            }
         }
     }
 
@@ -754,6 +759,7 @@ public class CloudTabletRebalancer extends MasterDaemon {
         BackendService.Client client = null;
         TNetworkAddress address = null;
         Backend destBackend = cloudSystemInfoService.getBackend(be);
+        boolean ok = true;
         try {
             address = new TNetworkAddress(destBackend.getHost(), 
destBackend.getBePort());
             client = ClientPool.backendPool.borrowObject(address);
@@ -770,9 +776,13 @@ public class CloudTabletRebalancer extends MasterDaemon {
             return result.getTaskDone();
         } catch (Exception e) {
             LOG.warn("send check pre cache rpc error. backend[{}]", 
destBackend.getId(), e);
-            ClientPool.backendPool.invalidateObject(address, client);
+            ok = false;
         } finally {
-            ClientPool.backendPool.returnObject(address, client);
+            if (ok) {
+                ClientPool.backendPool.returnObject(address, client);
+            } else {
+                ClientPool.backendPool.invalidateObject(address, client);
+            }
         }
         return null;
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
index c6fc3307fe0..dfd54e473f8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
@@ -257,9 +257,10 @@ public class ProfileManager extends MasterDaemon {
             client = ClientPool.backendPool.borrowObject(targetBackend);
         } catch (Exception e) {
             LOG.warn("Fetch a agent client failed, address: {}", 
targetBackend.toString());
+            ClientPool.backendPool.invalidateObject(targetBackend, client);
             return resp;
         }
-
+        boolean ok = true;
         try {
             TGetRealtimeExecStatusRequest req = new 
TGetRealtimeExecStatusRequest();
             req.setId(queryID);
@@ -267,9 +268,13 @@ public class ProfileManager extends MasterDaemon {
         } catch (TException e) {
             LOG.warn("Got exception when getRealtimeExecStatus, query {} 
backend {}",
                     DebugUtil.printId(queryID), targetBackend.toString(), e);
-            ClientPool.backendPool.invalidateObject(targetBackend, client);
+            ok = false;
         } finally {
-            ClientPool.backendPool.returnObject(targetBackend, client);
+            if (ok) {
+                ClientPool.backendPool.returnObject(targetBackend, client);
+            } else {
+                ClientPool.backendPool.invalidateObject(targetBackend, client);
+            }
         }
 
         if (!resp.isSetStatus()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to