Copilot commented on code in PR #18921:
URL: https://github.com/apache/iotdb/pull/18921#discussion_r4320759998


##########
iotdb-client/session/src/main/java/org/apache/iotdb/session/NodesSupplier.java:
##########
@@ -172,24 +186,54 @@ public List<TEndPoint> get() {
   }
 
   @Override
-  public void run() {
+  public List<TEndPoint> getSeedNodes() {
+    return seedNodes;
+  }
+
+  @Override
+  public void requestRefresh() {
+    if (!closed && refreshRequested.compareAndSet(false, true)) {
+      try {
+        executorService.execute(
+            () -> {
+              try {
+                run();
+              } finally {
+                refreshRequested.set(false);
+              }
+            });
+      } catch (RejectedExecutionException e) {
+        // The session or pool may have shut down its executor concurrently.
+        refreshRequested.set(false);
+      }
+    }
+  }
+
+  @Override
+  public synchronized void run() {

Review Comment:
   Synchronizing the entire refresh holds the cleanup monitor during connection 
setup. `close()` sets `closed` but then blocks in synchronized 
`destroyCurrentClient()`. If an endpoint does not respond, Session/SessionPool 
shutdown must wait for that attempt; the candidate loop never rechecks 
`closed`, so it also tries the remaining discovered endpoints and seeds. With 
the default connection timeout of zero, this can cause lengthy shutdown stalls. 
Serialize refresh runs separately from client cleanup, coordinate 
publication/cleanup of an in-flight client, and stop trying candidates once 
closure is requested. Add a test that closes the supplier during a blocked 
connection attempt.



##########
iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java:
##########
@@ -599,11 +605,7 @@ private static List<String> shuffleNodeUrls(List<String> 
endPoints) {
   }
 
   private List<TEndPoint> getNodeUrls() {
-    if (defaultEndPoint != null) {
-      return Collections.singletonList(defaultEndPoint);
-    } else {
-      return SessionUtils.parseSeedNodeUrls(nodeUrls);
-    }
+    return SessionUtils.parseSeedNodeUrls(initialNodeUrls);

Review Comment:
   Reopening a failed-over Session can strand discovery on an offline seed. For 
example, configure only seed A, discover B, fail over to B, then close and 
reopen while A is still unreachable. `open()` connects to the retained 
`defaultEndPoint` B, but the new supplier gets only A from this method. 
Background discovery never tries B, and query routing repeatedly attempts A 
before falling back to B, potentially adding a connection timeout to every 
query. Keep the original addresses as recovery seeds, but bootstrap discovery 
separately from the retained endpoint or snapshot. Add a close/reopen 
regression test for this case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to