This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 5ceb047fe83 Fix DataNode restart readiness race in IoTDBConnectionsIT
(#18192)
5ceb047fe83 is described below
commit 5ceb047fe83298e34acc1805cf336d8998bc25e9
Author: Caideyipi <[email protected]>
AuthorDate: Mon Jul 13 16:08:22 2026 +0800
Fix DataNode restart readiness race in IoTDBConnectionsIT (#18192)
---
.../iotdb/session/it/IoTDBConnectionsIT.java | 30 +++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBConnectionsIT.java
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBConnectionsIT.java
index 80aa854e66c..18b5f897e5c 100644
---
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBConnectionsIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBConnectionsIT.java
@@ -25,11 +25,13 @@ import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant;
import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
import org.apache.iotdb.itbase.env.BaseEnv;
+import org.awaitility.Awaitility;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -244,10 +246,12 @@ public class IoTDBConnectionsIT {
return;
}
int closedDataNodeId = (int) allDataNodeId.toArray()[0];
+ DataNodeWrapper closedDataNode =
+
EnvFactory.getEnv().dataNodeIdToWrapper(closedDataNodeId).orElseThrow();
try (Connection connection =
EnvFactory.getEnv()
.getConnection(
-
EnvFactory.getEnv().dataNodeIdToWrapper(closedDataNodeId).get(),
+ closedDataNode,
CommonDescriptor.getInstance().getConfig().getDefaultAdminName(),
CommonDescriptor.getInstance().getConfig().getAdminPassword(),
BaseEnv.TABLE_SQL_DIALECT);
@@ -269,7 +273,7 @@ public class IoTDBConnectionsIT {
}
// close the number closedDataNodeId datanode
- EnvFactory.getEnv().dataNodeIdToWrapper(closedDataNodeId).get().stop();
+ closedDataNode.stop();
try (SyncConfigNodeIServiceClient client =
(SyncConfigNodeIServiceClient)
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
@@ -319,7 +323,7 @@ public class IoTDBConnectionsIT {
}
// revert environment
- EnvFactory.getEnv().dataNodeIdToWrapper(closedDataNodeId).get().start();
+ closedDataNode.start();
try (SyncConfigNodeIServiceClient client =
(SyncConfigNodeIServiceClient)
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
// Wait for restart check
@@ -341,6 +345,26 @@ public class IoTDBConnectionsIT {
TimeUnit.SECONDS.sleep(1);
}
}
+
+ // The ConfigNode may report the restarted DataNode as Running before its
client RPC service is
+ // ready. Wait for a direct connection so that subsequent tests do not
race with the restart.
+ Awaitility.await()
+ .pollInterval(1, TimeUnit.SECONDS)
+ .atMost(30, TimeUnit.SECONDS)
+ .until(
+ () -> {
+ try (Connection ignored =
+ EnvFactory.getEnv()
+ .getWriteOnlyConnectionWithSpecifiedDataNode(
+ closedDataNode,
+
CommonDescriptor.getInstance().getConfig().getDefaultAdminName(),
+
CommonDescriptor.getInstance().getConfig().getAdminPassword(),
+ BaseEnv.TABLE_SQL_DIALECT)) {
+ return true;
+ } catch (SQLException e) {
+ return false;
+ }
+ });
}
@Test