Skip to content

Commit b256818

Browse files
authored
retries:Remove early commit for transparent retries with none remaining. (#10066) (#10080)
* retries:Remove early commit for transparent retries when no retries or no hedging remain. Fixes #10011
1 parent 21dda1d commit b256818

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

core/src/main/java/io/grpc/internal/RetriableStream.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -932,29 +932,15 @@ public void run() {
932932
return;
933933
}
934934
if (isHedging) {
935-
boolean commit = false;
936935
synchronized (lock) {
937936
// Although this operation is not done atomically with
938937
// noMoreTransparentRetry.compareAndSet(false, true), it does not change the size() of
939938
// activeHedges, so neither does it affect the commitment decision of other threads,
940939
// nor do the commitment decision making threads affect itself.
941940
state = state.replaceActiveHedge(substream, newSubstream);
942-
943-
// optimization for early commit
944-
if (!hasPotentialHedging(state)
945-
&& state.activeHedges.size() == 1) {
946-
commit = true;
947-
}
948-
}
949-
if (commit) {
950-
commitAndRun(newSubstream);
951-
}
952-
} else {
953-
if (retryPolicy == null || retryPolicy.maxAttempts == 1) {
954-
// optimization for early commit
955-
commitAndRun(newSubstream);
956941
}
957942
}
943+
958944
callExecutor.execute(new Runnable() {
959945
@Override
960946
public void run() {

core/src/test/java/io/grpc/internal/RetriableStreamTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ public void normalRetry_thenNoTransparentRetry_andNoMoreRetry() {
19711971
}
19721972

19731973
@Test
1974-
public void noRetry_transparentRetry_earlyCommit() {
1974+
public void noRetry_transparentRetry_noEarlyCommit() {
19751975
ClientStream mockStream1 = mock(ClientStream.class);
19761976
ClientStream mockStream2 = mock(ClientStream.class);
19771977
InOrder inOrder = inOrder(retriableStreamRecorder, mockStream1, mockStream2);
@@ -1999,7 +1999,7 @@ method, new Metadata(), channelBufferUsed, PER_RPC_BUFFER_LIMIT, CHANNEL_BUFFER_
19991999
inOrder.verify(retriableStreamRecorder).newSubstream(0);
20002000
ArgumentCaptor<ClientStreamListener> sublistenerCaptor2 =
20012001
ArgumentCaptor.forClass(ClientStreamListener.class);
2002-
inOrder.verify(retriableStreamRecorder).postCommit();
2002+
verify(retriableStreamRecorder, never()).postCommit();
20032003
inOrder.verify(mockStream2).start(sublistenerCaptor2.capture());
20042004
inOrder.verify(mockStream2).isReady();
20052005
inOrder.verifyNoMoreInteractions();

0 commit comments

Comments
 (0)