GeezerVison is showing github.com — core: Improve DEADLINE_EXCEEDED message for CallCreds delays · grpc/grpc-java@ead532b
File treeExpand file treeCollapse file tree Open diff view settings main/java/io/grpc/internal test/java/io/grpc/internal
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: core/src/main/java/io/grpc/internal/DelayedClientTransport.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -363,6 +363,7 @@ private class PendingStream extends DelayedStream { | 363 | 363 | private volatile Status lastPickStatus; | 364 | 364 |
| 365 | 365 | private PendingStream(PickSubchannelArgs args, ClientStreamTracer[] tracers) { | | 366 | + super("connecting_and_lb"); | 366 | 367 | this.args = args; | 367 | 368 | this.tracers = tracers; | 368 | 369 | } | |
Collapse file Copy file name to clipboardExpand all lines: core/src/main/java/io/grpc/internal/DelayedStream.java +14-3Lines changed: 14 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 42 | 42 | * necessary. | 43 | 43 | */ | 44 | 44 | class DelayedStream implements ClientStream { | | 45 | + private final String bufferContext; | 45 | 46 | /** {@code true} once realStream is valid and all pending calls have been drained. */ | 46 | 47 | private volatile boolean passThrough; | 47 | 48 | /** | @@ -64,6 +65,14 @@ class DelayedStream implements ClientStream { | 64 | 65 | // No need to synchronize; start() synchronization provides a happens-before | 65 | 66 | private List<Runnable> preStartPendingCalls = new ArrayList<>(); | 66 | 67 |
| | 68 | + /** | | 69 | + * Create a delayed stream with debug context {@code bufferContext}. The context is what this | | 70 | + * stream is delayed by (e.g., "connecting", "call_credentials"). | | 71 | + */ | | 72 | + public DelayedStream(String bufferContext) { | | 73 | + this.bufferContext = checkNotNull(bufferContext, "bufferContext"); | | 74 | + } | | 75 | + | 67 | 76 | @Override | 68 | 77 | public void setMaxInboundMessageSize(final int maxSize) { | 69 | 78 | checkState(listener == null, "May only be called before start"); | @@ -104,11 +113,13 @@ public void appendTimeoutInsight(InsightBuilder insight) { | 104 | 113 | return; | 105 | 114 | } | 106 | 115 | if (realStream != null) { | 107 | | - insight.appendKeyValue("buffered_nanos", streamSetTimeNanos - startTimeNanos); | | 116 | + insight.appendKeyValue( | | 117 | + bufferContext + "_delay", "" + (streamSetTimeNanos - startTimeNanos) + "ns"); | 108 | 118 | realStream.appendTimeoutInsight(insight); | 109 | 119 | } else { | 110 | | - insight.appendKeyValue("buffered_nanos", System.nanoTime() - startTimeNanos); | 111 | | - insight.append("waiting_for_connection"); | | 120 | + insight.appendKeyValue( | | 121 | + bufferContext + "_delay", "" + (System.nanoTime() - startTimeNanos) + "ns"); | | 122 | + insight.append("was_still_waiting"); | 112 | 123 | } | 113 | 124 | } | 114 | 125 | } | |
Collapse file Copy file name to clipboardExpand all lines: core/src/main/java/io/grpc/internal/MetadataApplierImpl.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -120,7 +120,7 @@ ClientStream returnStream() { | 120 | 120 | synchronized (lock) { | 121 | 121 | if (returnedStream == null) { | 122 | 122 | // apply() has not been called, needs to buffer the requests. | 123 | | - delayedStream = new DelayedStream(); | | 123 | + delayedStream = new DelayedStream("call_credentials"); | 124 | 124 | return returnedStream = delayedStream; | 125 | 125 | } else { | 126 | 126 | return returnedStream; | |
Collapse file Copy file name to clipboardExpand all lines: core/src/test/java/io/grpc/internal/DelayedClientTransportTest.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -742,7 +742,7 @@ public void pendingStream_appendTimeoutInsight_waitForReady() { | 742 | 742 | InsightBuilder insight = new InsightBuilder(); | 743 | 743 | stream.appendTimeoutInsight(insight); | 744 | 744 | assertThat(insight.toString()) | 745 | | - .matches("\\[wait_for_ready, buffered_nanos=[0-9]+\\, waiting_for_connection]"); | | 745 | + .matches("\\[wait_for_ready, connecting_and_lb_delay=[0-9]+ns\\, was_still_waiting]"); | 746 | 746 | } | 747 | 747 |
| 748 | 748 | @Test | @@ -759,7 +759,7 @@ public void pendingStream_appendTimeoutInsight_waitForReady_withLastPickFailure( | 759 | 759 | assertThat(insight.toString()) | 760 | 760 | .matches("\\[wait_for_ready, " | 761 | 761 | + "Last Pick Failure=Status\\{code=PERMISSION_DENIED, description=null, cause=null\\}," | 762 | | - + " buffered_nanos=[0-9]+, waiting_for_connection]"); | | 762 | + + " connecting_and_lb_delay=[0-9]+ns, was_still_waiting]"); | 763 | 763 | } | 764 | 764 |
| 765 | 765 | private static TransportProvider newTransportProvider(final ClientTransport transport) { | |
Collapse file Copy file name to clipboardExpand all lines: core/src/test/java/io/grpc/internal/DelayedStreamTest.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -71,7 +71,7 @@ public class DelayedStreamTest { | 71 | 71 | @Mock private ClientStreamListener listener; | 72 | 72 | @Mock private ClientStream realStream; | 73 | 73 | @Captor private ArgumentCaptor<ClientStreamListener> listenerCaptor; | 74 | | - private DelayedStream stream = new DelayedStream(); | | 74 | + private DelayedStream stream = new DelayedStream("test_op"); | 75 | 75 |
| 76 | 76 | @Test | 77 | 77 | public void setStream_setAuthority() { | @@ -450,7 +450,7 @@ public void appendTimeoutInsight_realStreamNotSet() { | 450 | 450 | InsightBuilder insight = new InsightBuilder(); | 451 | 451 | stream.start(listener); | 452 | 452 | stream.appendTimeoutInsight(insight); | 453 | | - assertThat(insight.toString()).matches("\\[buffered_nanos=[0-9]+\\, waiting_for_connection]"); | | 453 | + assertThat(insight.toString()).matches("\\[test_op_delay=[0-9]+ns\\, was_still_waiting]"); | 454 | 454 | } | 455 | 455 |
| 456 | 456 | @Test | @@ -469,7 +469,7 @@ public Void answer(InvocationOnMock in) { | 469 | 469 | InsightBuilder insight = new InsightBuilder(); | 470 | 470 | stream.appendTimeoutInsight(insight); | 471 | 471 | assertThat(insight.toString()) | 472 | | - .matches("\\[buffered_nanos=[0-9]+, remote_addr=127\\.0\\.0\\.1:443\\]"); | | 472 | + .matches("\\[test_op_delay=[0-9]+ns, remote_addr=127\\.0\\.0\\.1:443\\]"); | 473 | 473 | } | 474 | 474 |
| 475 | 475 | private void callMeMaybe(Runnable r) { | |
|