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

Context WithTimeout duration infinity causes context deadline to receive date "1726-07-03" #2374

Closed
kushtrimjunuzi opened this issue Oct 12, 2018 · 1 comment · Fixed by #2379
Assignees

Comments

@kushtrimjunuzi
Copy link

What version of gRPC are you using?

grpc-go/1.15.0

What version of Go are you using (go version)?

go1.8.3

What operating system (Linux, Windows, …) and version?

linux/amd64

What did you do?

I started to play with envoy proxy and based on some configurations that I had to do for grpc streaming services for clients such as specifying context.WithTimeout in order for envoy to pickup "grpc-timeout" header and resets router timeout there. I had very hard time troubleshooting this issue and it is reproducible.

client side:

infinity := time.Duration(math.MaxInt64)
ctx, close := context.WithTimeout(somectx, infinity)
defer close()
c := pb.NewMessageEventServiceClient(conn)
stream, err := c.Events(ctx, &pb.MessageEventRequest{}) 
...

envoy request headers:

ger_impl.cc:521] [C27][S12562730267543745879] request headers complete (end_stream=false):
envoylb.1.zxftixklx4lk@idkdev    | ':method', 'POST'
envoylb.1.zxftixklx4lk@idkdev    | ':scheme', 'http'
envoylb.1.zxftixklx4lk@idkdev    | ':path', '/grpc.MessageEventService'
envoylb.1.zxftixklx4lk@idkdev    | ':authority', 'envoylb:8002'
envoylb.1.zxftixklx4lk@idkdev    | 'content-type', 'application/grpc'
envoylb.1.zxftixklx4lk@idkdev    | 'user-agent', 'grpc-go/1.15.0'
envoylb.1.zxftixklx4lk@idkdev    | 'te', 'trailers'
envoylb.1.zxftixklx4lk@idkdev    | 'grpc-timeout', '2562048H'

Using infinity timeout is causing the context deadline (deadline, ok := ctx.Deadline()) at the server to receive as "1726-07-03" back in time, and of course closing the connection.
If you use context.WithTimeout(somectx, time.Second*something) or any duration you like except math.MaxInt64, then everything works as expected.

What did you expect to see?

I expected to so context deadline as "2311-01-22".

What did you see instead?

Instead context deadline is "1726-07-03"

Thanks.

@dfawley
Copy link
Member

dfawley commented Oct 12, 2018

Thanks for the report @kushtrimjunuzi.

Without digging in, this seems likely: 2562048H overflows int64. MaxInt64 -> Hours should be 2562047h47m16.854775807s. Because of the round-up, we overflow when converting back.

@dfawley dfawley self-assigned this Oct 15, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Apr 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants