This is an automated email from the ASF dual-hosted git repository.
jiangtian 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 8e7605f80db Fix cache invalidation failure and add retry (#14711)
8e7605f80db is described below
commit 8e7605f80db131d4bb5ce524afe3b3a1dab15c81
Author: Jiang Tian <[email protected]>
AuthorDate: Fri Jan 17 09:35:20 2025 +0800
Fix cache invalidation failure and add retry (#14711)
* Fix cache invalidation failure and add retry
* spotless
---
.../iotdb/session/it/IoTDBSessionSimpleIT.java | 23 ++++++++++++++++++++++
.../procedure/env/ConfigNodeProcedureEnv.java | 19 +++++++++++-------
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
index 4ca5c1fd2e2..55c5523b2a5 100644
---
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
@@ -1898,4 +1898,27 @@ public class IoTDBSessionSimpleIT {
e.printStackTrace();
}
}
+
+ @Test
+ public void testWriteRestartAndDeleteDB()
+ throws IoTDBConnectionException, StatementExecutionException {
+ try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
+ session.insertRecord("root.sg1.d1", 1, Arrays.asList("s3"),
Arrays.asList("1"));
+
+ TestUtils.stopForciblyAndRestartDataNodes();
+
+ SessionDataSet dataSet = session.executeQueryStatement("select s3 from
root.sg1.d1");
+ dataSet.next();
+ dataSet.close();
+
+ session.executeNonQueryStatement("DELETE DATABASE root.sg1");
+
+ session.insertRecord(
+ "root.sg1.d1", 1, Arrays.asList("s1", "s2", "s3"),
Arrays.asList("1", "1", "1"));
+
+ dataSet = session.executeQueryStatement("SELECT * FROM root.sg1.d1");
+ RowRecord record = dataSet.next();
+ assertEquals(3, record.getFields().size());
+ }
+ }
}
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
index a16e03da8fb..e721e3dd014 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/ConfigNodeProcedureEnv.java
@@ -167,16 +167,20 @@ public class ConfigNodeProcedureEnv {
for (TDataNodeConfiguration dataNodeConfiguration : allDataNodes) {
int dataNodeId = dataNodeConfiguration.getLocation().getDataNodeId();
- // If the node is not alive, sleep 1 second and try again
+ // If the node is not alive, retry for up to 10 times
NodeStatus nodeStatus = getLoadManager().getNodeStatus(dataNodeId);
+ int retryNum = 10;
if (nodeStatus == NodeStatus.Unknown) {
- try {
- TimeUnit.MILLISECONDS.sleep(1000);
- } catch (InterruptedException e) {
- LOG.error("Sleep failed in ConfigNodeProcedureEnv: ", e);
- Thread.currentThread().interrupt();
+ for (int i = 0; i < retryNum && nodeStatus == NodeStatus.Unknown; i++)
{
+ try {
+ TimeUnit.MILLISECONDS.sleep(500);
+ } catch (InterruptedException e) {
+ LOG.error("Sleep failed in ConfigNodeProcedureEnv: ", e);
+ Thread.currentThread().interrupt();
+ break;
+ }
+ nodeStatus = getLoadManager().getNodeStatus(dataNodeId);
}
- nodeStatus = getLoadManager().getNodeStatus(dataNodeId);
}
if (nodeStatus == NodeStatus.Running) {
@@ -208,6 +212,7 @@ public class ConfigNodeProcedureEnv {
LOG.warn(
"Invalidate cache failed, because DataNode {} is Unknown",
dataNodeConfiguration.getLocation().getInternalEndPoint());
+ return false;
}
}
return true;