Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client: server-streaming does not collect duplicated (fault+ctx) trailers during an RpcException #915

Closed
mgravell opened this issue May 20, 2020 · 1 comment · Fixed by #918
Labels
bug Something isn't working

Comments

@mgravell
Copy link
Contributor

mgravell commented May 20, 2020

Scenario: the server (native in this case) deliberately faults with an RpcException including some trailers in the middle of a server-streaming operation, and that trailer has also been added to the server context, i.e.

var faultTrailers = new Metadata();
faultTrailers.Add("sum", sum);
// **and** importantly
serverContext.ResponseTrailers.Add("sum", sum);
throw new RpcException(new Status(StatusCode.Internal, "oops"), faultTrailers);

Expectation

as observed with the native Google client:

The client-side call await streamReader.MoveNext(cancellationToken) will surface an RpcException with the correct StatusCode, Detail and Trailers i.e. one of "sum", sum

Actual

as observed with Grpc-Dotnet

The client-side call await streamReader.MoveNext(cancellationToken) surfaces an RpcException with the correct StatusCode, Detail - but:

  • sometimes the Trailers collection is empty
  • sometimes the Trailers collection has it twice, i.e. "sum", "10,10"

I haven't figured out the rules for when it is empty and when it is duplicated; when I run just the one test, it tends to be empty; when I run a bunch of tests it tends to be duplicated. Possibly a thread race condition.

Repro

See the ServerStreaming(true) test case here - comparing NativeStreamTests to ManagedStreamTests.

A good place to put a breakpoint is in Reshape.cs, ServerStreamingAsyncImpl, on the line:

metadata?.SetTrailers(fault);

(which is where the exception is surfaced)

Note that this is the exact same (native) server in both tests, so presumably this is a client bug.

Note: I have added IsManagedClient that changes the test's expectation to reflect what I am observing (so my tests acknowledge reality for now)

@mgravell mgravell added the bug Something isn't working label May 20, 2020
mgravell added a commit to protobuf-net/protobuf-net.Grpc that referenced this issue May 20, 2020
mgravell added a commit to protobuf-net/protobuf-net.Grpc that referenced this issue May 20, 2020
mgravell added a commit to protobuf-net/protobuf-net.Grpc that referenced this issue May 20, 2020
mgravell added a commit to protobuf-net/protobuf-net.Grpc that referenced this issue May 20, 2020
@mgravell mgravell changed the title Client: server-streaming does not collect trailers during an RpcException Client: server-streaming does not collect duplicated (fault+ctx) trailers during an RpcException May 20, 2020
@JamesNK
Copy link
Member

JamesNK commented Jul 16, 2020

@mgravell 2.30.0 is on NuGet with this fix. You can update your package reference and remove any related hacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants