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

jackietien pushed a commit to branch ty/useXX
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/ty/useXX by this push:
     new c3668486296 change Session
c3668486296 is described below

commit c36684862962b0616d57836e5cd15626107c7db8
Author: JackieTien97 <[email protected]>
AuthorDate: Tue Jul 9 11:11:35 2024 +0800

    change Session
---
 .../src/main/java/org/apache/iotdb/session/Session.java   | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
index 5e0d205a3b5..087b38b73b8 100644
--- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
+++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java
@@ -951,8 +951,19 @@ public class Session implements ISession {
     String previousDB = database;
     defaultSessionConnection.executeNonQueryStatement(sql);
     if (!Objects.equals(previousDB, database) && endPointToSessionConnection 
!= null) {
-      for (SessionConnection sessionConnection : 
endPointToSessionConnection.values()) {
-        sessionConnection.executeNonQueryStatement(sql);
+      Iterator<Map.Entry<TEndPoint, SessionConnection>> iterator =
+          endPointToSessionConnection.entrySet().iterator();
+      while (iterator.hasNext()) {
+        Map.Entry<TEndPoint, SessionConnection> entry = iterator.next();
+        SessionConnection sessionConnection = entry.getValue();
+        if (sessionConnection != defaultSessionConnection) {
+          try {
+            sessionConnection.executeNonQueryStatement(sql);
+          } catch (Throwable t) {
+            logger.warn("failed to change database for {}", entry.getKey());
+            iterator.remove();
+          }
+        }
       }
     }
   }

Reply via email to