This is an automated email from the ASF dual-hosted git repository.
JackieTien97 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 4886d3c8bc4 fix that metadata high available frame could recognize the
timeout exception (#19206)
4886d3c8bc4 is described below
commit 4886d3c8bc462b53b4438fb05e3d0d156afda599
Author: alpass163 <[email protected]>
AuthorDate: Wed Nov 11 10:43:46 2026 +0800
fix that metadata high available frame could recognize the timeout
exception (#19206)
---
.../handlers/rpc/DataNodeTSStatusRPCHandler.java | 8 ++++-
.../manager/lease/ClusterCachePropagatorTest.java | 42 ++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java
index c0bf63645e2..af1f6dba1f3 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/handlers/rpc/DataNodeTSStatusRPCHandler.java
@@ -35,6 +35,7 @@ import java.net.ConnectException;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeoutException;
/** General RPC handler for TSStatus response type. */
public class DataNodeTSStatusRPCHandler extends
DataNodeAsyncRequestRPCHandler<TSStatus> {
@@ -81,8 +82,13 @@ public class DataNodeTSStatusRPCHandler extends
DataNodeAsyncRequestRPCHandler<T
logFailure(errorMsg);
// the DN throw Exception -> TApplicationException
// the DN crash -> TTransportException or ConnectException
+ // the thrift frame timeout -> TimeoutException
+ // A timeout means no response was received, not that the DataNode failed
to execute the
+ // request.
int code =
- e instanceof TTransportException || e instanceof ConnectException
+ e instanceof TTransportException
+ || e instanceof ConnectException
+ || e instanceof TimeoutException
? TSStatusCode.CAN_NOT_CONNECT_DATANODE.getStatusCode()
: TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode();
diff --git
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/lease/ClusterCachePropagatorTest.java
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/lease/ClusterCachePropagatorTest.java
index 00ccd9cd8f4..065a1c40c29 100644
---
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/lease/ClusterCachePropagatorTest.java
+++
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/lease/ClusterCachePropagatorTest.java
@@ -21,14 +21,19 @@ package org.apache.iotdb.confignode.manager.lease;
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.confignode.client.async.CnToDnAsyncRequestType;
+import
org.apache.iotdb.confignode.client.async.handlers.rpc.DataNodeTSStatusRPCHandler;
import
org.apache.iotdb.confignode.manager.lease.MetadataBroadcastVerdict.Verdict;
import org.apache.iotdb.rpc.TSStatusCode;
+import org.apache.thrift.TApplicationException;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.IntToLongFunction;
@@ -174,6 +179,43 @@ public class ClusterCachePropagatorTest {
Assert.assertFalse(p.propagate(targets -> ackOnly(1)));
}
+ @Test
+ public void rpcTimeoutResponseFollowsFenceVerdict() {
+ final AtomicLong heartbeatAgeMs = new AtomicLong(10_000L);
+ final ClusterCachePropagator p = propagator(id -> heartbeatAgeMs.get());
+ final Map<Integer, TSStatus> responses = responseFromError(new
TimeoutException());
+ Assert.assertEquals(
+ TSStatusCode.CAN_NOT_CONNECT_DATANODE.getStatusCode(),
responses.get(2).getCode());
+ Assert.assertEquals(Verdict.WAIT, p.propagateOnce(targets -> responses,
false));
+ Assert.assertEquals(Verdict.FAIL, p.propagateOnce(targets -> responses,
true));
+
+ heartbeatAgeMs.set(FENCE_TIMEOUT_MS);
+ Assert.assertEquals(Verdict.PROCEED, p.propagateOnce(targets -> responses,
false));
+ Assert.assertEquals(Verdict.PROCEED, p.propagateOnce(targets -> responses,
true));
+ }
+
+ @Test
+ public void rpcApplicationErrorStillFailsAfterFenceTimeout() {
+ final Map<Integer, TSStatus> responses = responseFromError(new
TApplicationException());
+ Assert.assertEquals(
+ TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(),
responses.get(2).getCode());
+ Assert.assertEquals(
+ Verdict.FAIL,
+ propagator(id -> FENCE_TIMEOUT_MS + 1).propagateOnce(targets ->
responses, false));
+ }
+
+ private Map<Integer, TSStatus> responseFromError(final Exception exception) {
+ final Map<Integer, TDataNodeLocation> targets = twoDataNodes();
+ final Map<Integer, TSStatus> responses = ackOnly(1);
+ final CountDownLatch latch = new CountDownLatch(1);
+ new DataNodeTSStatusRPCHandler(
+ CnToDnAsyncRequestType.UPDATE_TABLE, 2, targets.get(2), targets,
responses, latch)
+ .onError(exception);
+ Assert.assertEquals(0L, latch.getCount());
+ Assert.assertTrue(targets.containsKey(2));
+ return responses;
+ }
+
private Map<Integer, TSStatus> ackOnly(final int nodeId) {
final Map<Integer, TSStatus> r = new HashMap<>();
r.put(nodeId, success());