-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Server should send RST_STREAM when deadline is exceeded #2886
Comments
Note that this may have interactions with ServerInHandle, if ServerInHandle changes the deadline. It is only appropriate to use RST_STREAM when the client specified its deadline, since in that case the client will ignore what the server sends anyway. If the ServerInHandler reduced the deadline, then a normal close is appropriate. |
@purnesh42H Please assign to me |
@purnesh42H please assign me this issue |
I was going through the code to understand the parts responsible for sending RST_STREAM frames on context timeouts. It seems that only gRPC Go clients send RST_STREAMs on context expiration though two different paths. First pathTo read data from a stream, both server and client streams call the read method on the shared grpc-go/internal/transport/client_stream.go Lines 54 to 60 in ee3e8d9
grpc-go/internal/transport/server_stream.go Lines 53 to 59 in ee3e8d9
Stream.read() eventually calls the recvBufferReader.Read. This method has different paths for server and client streams: grpc-go/internal/transport/transport.go Lines 167 to 171 in ee3e8d9
grpc-go/internal/transport/transport.go Lines 220 to 241 in ee3e8d9
grpc-go/internal/transport/client_stream.go Lines 62 to 73 in ee3e8d9
Second pathFor non-unary streams on the client side, a separate goroutine is spawned which monitors the channel and stream context cancellations and call Lines 388 to 402 in ee3e8d9
|
The server code relies on the application to return when the deadline is exceeded. But when it does return, it doesn't cancel the RPC; it sends a graceful close:
https://github.com/grpc/grpc-go/blob/v1.21.1/server.go#L1010
If the deadline is exceeded when the handler returns, the RPC should be cancelled and RST_STREAM should be sent (if one hasn't already been received from the client).
The text was updated successfully, but these errors were encountered: