This sounds like auto-cancellation. When a RPC completes on the server, the
server's io.grpc.Context is cancelled. That propagates to any outgoing
RPCs. This is the same wiring that will cancel those RPCs when the initial
RPC is cancelled and provides deadline propagation.

I think you want to run the RPC to Server B within a forked context. For
example: Context.current().fork().run(yourStuff);

Carl: it looks like Contexts
<https://github.com/grpc/grpc-java/blob/166108a/core/src/main/java/io/grpc/Contexts.java#L136>
is the source of this description-less Status. I'll send out a PR.

On Mon, Oct 30, 2017 at 5:16 PM, 'Carl Mastrangelo' via grpc.io <
[email protected]> wrote:

> I'm not sure where that RST Stream is coming from but I sent out
> https://github.com/grpc/grpc-java/pull/3642   to try and find the source
> of the error.
>
>
> On Tuesday, October 24, 2017 at 7:21:20 AM UTC-7, [email protected]
> wrote:
>>
>> Maybe a bit more information on what happens, once I get the exception:
>> My StreamObserver.onError gets called, and the error gets handled
>> correctly (in a thread from the channel's executor).
>>
>> On Tuesday, October 24, 2017 at 4:12:25 PM UTC+2, [email protected]
>> wrote:
>>>
>>>
>>> Hi all,
>>>
>>> I've been experimenting with the following scenario.
>>>
>>> Service A gets a synchronous GRPC call (handled by thread-A from the
>>> default grpc thread pool). Within that call, it calls Service B via an
>>> asynchronous call (stub). It provides a StreamObserver and expects a
>>> streamed response from Service B. The ManagedChannel to Service B has it's
>>> own executor (though the problem persists with default executor as well).
>>>
>>>
>>> Once, the thread-A calls Service B asynchronously, it returns and
>>> finishes.
>>>
>>> Observation:
>>> In the moment, when thread-A
>>> finishes, the request to Service B gets cancelled. (Status: CANCELLED,
>>> see Stacktrace below).
>>>
>>> io.grpc.StatusRuntimeException: CANCELLED
>>>  at io.grpc.Status.asRuntimeException(Status.java:526) ~[grpc-core-1.5.
>>> 0.jar:1.5.0]
>>>  at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose
>>> (ClientCalls.java:380) [grpc-stub-1.5.0.jar:1.5.0]
>>>  at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:
>>> 419) [grpc-core-1.5.0.jar:1.5.0]
>>>  at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:60) [
>>> grpc-core-1.5.0.jar:1.5.0]
>>>  at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(
>>> ClientCallImpl.java:493) [grpc-core-1.5.0.jar:1.5.0]
>>>  at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$500(
>>> ClientCallImpl.java:422) [grpc-core-1.5.0.jar:1.5.0]
>>>  at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1St
>>> reamClosed.runInContext(ClientCallImpl.java:525) [grpc-core-1.5.0.jar:
>>> 1.5.0]
>>>  at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) [grpc-
>>> core-1.5.0.jar:1.5.0]
>>>  at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:
>>> 102) [grpc-core-1.5.0.jar:1.5.0]
>>>  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor
>>> .java:1142) [?:1.8.0_40]
>>>  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>>> lExecutor.java:617) [?:1.8.0_40]
>>>  at java.lang.Thread.run(Thread.java:745) [?:1.8.0_40]
>>>
>>>
>>>
>>> If I debug and put a breakpoint before thread-A returns (breakpoint that
>>> only stops thread-A), the call to Service B is successful, the streamed
>>> responses get handled correctly by threads of the executor from B's channel
>>> etc. As soon as I let thread-A finish, I run again into the exception
>>> above.
>>>
>>> Can you think of an explanation for this?
>>> Why can't the calling thread of an async thread not be finished?
>>> Shouldn't it be enough to pass the StreamObserver to the async call?
>>>
>>>
>>> Looking forward to your help and happy to provide further details!
>>>
>> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/dc5e0c86-3722-4858-8a2a-1bf2fb250b70%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/dc5e0c86-3722-4858-8a2a-1bf2fb250b70%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oNwBd0GZo8jaUcvXjfAr-9WV5H_yXgFXyUXTn14vTe8dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to