You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by "siyao.apache.org via common-commits" <co...@hadoop.apache.org> on 2026/10/31 19:37:36 UTC
(hadoop) branch branch-3.4 updated: HADOOP-20047. RetryInvocationHandler leaves the call id set when an attempt issues no RPC (#8902)
This is an automated email from the ASF dual-hosted git repository.
smengcl pushed a commit to branch branch-3.4
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.4 by this push:
new b624a220778 HADOOP-20047. RetryInvocationHandler leaves the call id set when an attempt issues no RPC (#8902)
b624a220778 is described below
commit b624a22077844e9f6ade7a633e58c083b94fb86d
Author: Siyao Meng <50...@users.noreply.github.com>
AuthorDate: Sat Oct 31 12:27:07 2026 -0700
HADOOP-20047. RetryInvocationHandler leaves the call id set when an attempt issues no RPC (#8902)
Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
(cherry picked from commit 6c0c1ca9164ac7566c3a19883c097c7de54bb9ec)
---
.../hadoop/io/retry/RetryInvocationHandler.java | 12 ++++++++--
.../org/apache/hadoop/io/retry/TestRetryProxy.java | 28 ++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
index 9707ee388e1..1d43ed40440 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
@@ -163,11 +163,19 @@ CallReturn invoke() throws Throwable {
}
Object invokeMethod() throws Throwable {
- if (isRpc && SET_CALL_ID_FOR_TEST.get()) {
+ final boolean setCallId = isRpc && SET_CALL_ID_FOR_TEST.get();
+ if (setCallId) {
Client.setCallIdAndRetryCount(callId, counters.retries,
retryInvocationHandler.asyncCallHandler);
}
- return retryInvocationHandler.invokeMethod(method, args);
+ try {
+ return retryInvocationHandler.invokeMethod(method, args);
+ } finally {
+ if (setCallId) {
+ // Clear what this attempt set, even if no RPC consumed it.
+ Client.setCallIdAndRetryCountUnprotected(null, 0, null);
+ }
+ }
}
@Override
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java
index 59b9b13fbff..6b8d2cabf0a 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java
@@ -25,6 +25,7 @@
import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException;
import org.apache.hadoop.ipc.ProtocolTranslator;
import org.apache.hadoop.ipc.RemoteException;
+import org.apache.hadoop.ipc.RpcInvocationHandler;
import org.apache.hadoop.security.AccessControlException;
import org.junit.Before;
import org.junit.Test;
@@ -33,6 +34,7 @@
import java.io.IOException;
import java.io.InterruptedIOException;
+import java.lang.reflect.Proxy;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.Collections;
import java.util.Map;
@@ -396,4 +398,30 @@ public void testWrappedAccessControlException() throws Exception {
assertEquals(RetryDecision.FAIL, caughtRetryAction.action);
}
}
+
+ @Test
+ public void testCallIdClearedWhenNoRpcIsIssued() throws Exception {
+ // A translator over an RPC proxy makes the handler set the call id for the
+ // next RPC; this translator throws before issuing it, so nothing consumes it.
+ final Object rpcProxy = Proxy.newProxyInstance(
+ UnreliableInterface.class.getClassLoader(),
+ new Class<?>[] {UnreliableInterface.class},
+ mock(RpcInvocationHandler.class));
+ class UnreliableTranslator extends UnreliableImplementation
+ implements ProtocolTranslator {
+ @Override
+ public Object getUnderlyingProxyObject() {
+ return rpcProxy;
+ }
+ }
+
+ UnreliableInterface unreliable = (UnreliableInterface) RetryProxy.create(
+ UnreliableInterface.class, new UnreliableTranslator(), TRY_ONCE_THEN_FAIL);
+ // A method that issues no RPC, such as toString, must not leave the call id set either.
+ assertNotNull(unreliable.toString());
+ for (int i = 0; i < 2; i++) {
+ // Without the call id being cleared, these calls fail with IllegalStateException.
+ assertThrows(FatalException.class, unreliable::alwaysFailsWithFatalException);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org