Commit Graph

8 Commits

Author SHA1 Message Date
Paul Chesnais 9ab8b62505
Implement new Codec that uses `mem.BufferSlice` instead of `[]byte` (#7356) 2024-08-21 14:11:39 -07:00
Doug Fawley 4832debdaa
test: clean up deadlines set in tests (#6506) 2023-08-08 09:23:15 -07:00
Easwar Swaminathan bfb57b8b49
testing: delete internal copy of test service proto, and use canonical one (#6164) 2023-04-05 17:12:57 -07:00
Doug Fawley 0d6a24f68a
test: move stubServer to separate package in internal (#4081) 2020-12-04 15:56:07 -08:00
Doug Fawley 663e4ce0c9
client: fix race between client-side stream cancellation and compressed server data arriving (#3054)
`transport/Stream.RecvCompress` returns what the header contains, if present,
or empty string if a context error occurs.  However, it "prefers" the header
data even if there is a context error, to prevent a related race.  What happens
here is:

1. RPC starts.

2. Client cancels RPC.

3. `RecvCompress` tells `ClientStream.Recv` that compression used is "" because
   of the context error.  `as.decomp` is left nil, because there is no
   compressor to look up in the registry.

4. Server's header and first message hit client.

5. Client sees the header and message and allows grpc's stream to see them.
   (We only provide context errors if we need to block.)

6. Client performs a successful `Read` on the stream, receiving the gzipped
   payload, then checks `as.decomp`.

7. We have no decompressor but the payload has a bit set indicating the message
   is compressed, so this is an error.  However, when forming the error string,
   `RecvCompress` now returns "gzip" because it doesn't need to block to get
   this from the now-received header.  This leads to the confusing message
   about how "gzip" is not installed even though it is.

This change makes `waitOnHeader` close the stream when context cancellation happens.
Then `RecvCompress` uses whatever value is present in the stream at that time, which
can no longer change because the stream is closed.  Also, this will be in sync with
the messages on the stream - if there are any messages present, the headers must
have been processed first, and `RecvCompress` will contain the proper value.
2019-10-01 10:47:40 -07:00
Menghan Li ee87494b1f transport: fix race between header and RPC cancellation (#2947) 2019-08-12 08:51:22 -07:00
Can Guler 9225666342
Modified binary search for the correct delay. (#2584)
* Binary search for the correct delay.

* Removes an unnecessary log line.

* Fixes.

* Switches back to linear search.

* Replaces cancel with a timeout.
2019-01-23 14:49:11 -08:00
Can Guler 9e7c146356
Return nil trailer metadata, if the RPC's status is context canceled. (#2554)
* Closes the client transport stream, if context is cancelled while recvBuffer is reading.

* Passes a function pointer to recvBufferReader, instead of a Stream and an http2Client.

* Adds more descriptive error messages.

* If waitOnHeader notices the context cancelation, shouldRetry no longer returns a ContextError. Instead, it returns the error from the last try.

* Makes sure that test gets both statuses at least 5 times.

* Makse cntPermDenied a lambda function.
2019-01-14 10:59:44 -08:00