-
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 sometimes returns "rpc error: code = Unknown" instead of "code = codees.DeadlineExceeded" #5155
Comments
I believe the reason is that the We expect the errors returned by service handlers are status errors (errors produced by the status package). I will update this issue later when we have a decision. |
Please see fix in #5156 |
Wow thanks for a prompt response and fix @menghanl! 🙂 I'll take a look and post back first thing tomorrow! |
I just ran your commit with the affected test in my codebase with
TIL - it looks like we have a Thanks again for all your help! |
What version of gRPC are you using?
Tested on 1.41.0 and master commit f93e8e6.
What version of Go are you using (
go version
)?1.17.2
What operating system (Linux, Windows, …) and version?
Linux, Ubuntu 20.04 LTS
What did you do?
I discovered a flaky unit test in a private code base. The test performs the following steps:
ctx, _ = context.WithTimeout(context.Background(), 50 * time.Millisecond)
. This method returns astream
.stream.Recv
in a loop until it receives an error.What did you expect to see?
In >99% of the cases we can successfully assert that
status.Code(err) == codes.DeadlineExceeded
.The error string is:
rpc error: code = DeadlineExceeded desc = context deadline exceeded
.What did you see instead?
In <1% of the cases we see
status.Code(err)
is equal tocodes.Unknown
.The error string is:
rpc error: code = Unknown desc = context deadline exceeded
.It's very hard to reproduce this bug, I think it's because there are a few different places where the errors are handled concurrently, and it probably also depends on the Go's scheduler.
However, I believe I was able to track down the cause in the code. After I replace one single line I'm no longer able to reproduce this issue, even after over 1000 test runs:
grpc-go/server.go
Line 1552 in f93e8e6
The text was updated successfully, but these errors were encountered: