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

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 2b6e181505c branch-4.1: [fix](connection) Prevent timeout checker from 
stopping after an exception #65040 (#65063)
2b6e181505c is described below

commit 2b6e181505c30f3121f3850eeea53e0234353d58
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jul 1 17:11:47 2026 +0800

    branch-4.1: [fix](connection) Prevent timeout checker from stopping after 
an exception #65040 (#65063)
    
    Cherry-picked from #65040
    
    Co-authored-by: feiniaofeiafei <[email protected]>
---
 .../java/org/apache/doris/qe/ConnectPoolMgr.java   |  7 ++++-
 .../java/org/apache/doris/qe/ConnectScheduler.java | 10 ++++--
 .../org/apache/doris/qe/ConnectSchedulerTest.java  | 36 ++++++++++++++++++++++
 3 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectPoolMgr.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectPoolMgr.java
index b64bcdd9284..643908e52c1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectPoolMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectPoolMgr.java
@@ -53,7 +53,12 @@ public class ConnectPoolMgr {
 
     public void timeoutChecker(long now) {
         for (ConnectContext connectContext : connectionMap.values()) {
-            connectContext.checkTimeout(now);
+            try {
+                connectContext.checkTimeout(now);
+            } catch (Throwable t) {
+                LOG.warn("failed to check timeout for connection, 
connectionId: {}, user: {}",
+                        connectContext.getConnectionId(), 
connectContext.getQualifiedUser(), t);
+            }
         }
     }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectScheduler.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectScheduler.java
index 32ea481fa9f..b22e89cf209 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectScheduler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectScheduler.java
@@ -160,9 +160,13 @@ public class ConnectScheduler {
     private class TimeoutChecker extends TimerTask {
         @Override
         public void run() {
-            long now = System.currentTimeMillis();
-            connectPoolMgr.timeoutChecker(now);
-            flightSqlConnectPoolMgr.timeoutChecker(now);
+            try {
+                long now = System.currentTimeMillis();
+                connectPoolMgr.timeoutChecker(now);
+                flightSqlConnectPoolMgr.timeoutChecker(now);
+            } catch (Throwable t) {
+                LOG.warn("failed to check connection timeout", t);
+            }
         }
     }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/qe/ConnectSchedulerTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/qe/ConnectSchedulerTest.java
index 9898a7cf1d4..7f750d37dee 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/qe/ConnectSchedulerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/qe/ConnectSchedulerTest.java
@@ -31,6 +31,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.nio.channels.SocketChannel;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
 public class ConnectSchedulerTest {
@@ -105,4 +106,39 @@ public class ConnectSchedulerTest {
         ConnectContext context = new ConnectContext();
         Assert.assertTrue(scheduler.submit(context));
     }
+
+    @Test
+    public void testTimeoutCheckerContinuesAfterContextException() {
+        ConnectPoolMgr connectPoolMgr = new ConnectPoolMgr(10);
+        ThrowingConnectContext throwingContext = new ThrowingConnectContext();
+        CountingConnectContext countingContext = new CountingConnectContext();
+        throwingContext.setConnectionId(1);
+        countingContext.setConnectionId(2);
+        
connectPoolMgr.getConnectionMap().put(throwingContext.getConnectionId(), 
throwingContext);
+        
connectPoolMgr.getConnectionMap().put(countingContext.getConnectionId(), 
countingContext);
+
+        connectPoolMgr.timeoutChecker(System.currentTimeMillis());
+
+        Assert.assertEquals(1, throwingContext.checkCount.get());
+        Assert.assertEquals(1, countingContext.checkCount.get());
+    }
+
+    private static class ThrowingConnectContext extends ConnectContext {
+        private final AtomicInteger checkCount = new AtomicInteger(0);
+
+        @Override
+        public void checkTimeout(long now) {
+            checkCount.incrementAndGet();
+            throw new RuntimeException("mock check timeout exception");
+        }
+    }
+
+    private static class CountingConnectContext extends ConnectContext {
+        private final AtomicInteger checkCount = new AtomicInteger(0);
+
+        @Override
+        public void checkTimeout(long now) {
+            checkCount.incrementAndGet();
+        }
+    }
 }


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

Reply via email to