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

x/net/http2: finish Transport.IdleConnTimeout #16808

Closed
bradfitz opened this issue Aug 19, 2016 · 3 comments
Closed

x/net/http2: finish Transport.IdleConnTimeout #16808

bradfitz opened this issue Aug 19, 2016 · 3 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

Go 1.7 added:

go1.7.txt:pkg net/http, type Transport struct, IdleConnTimeout time.Duration

But I don't think the http2.Transport entirely respects it. Make sure it does.

@bradfitz bradfitz added this to the Go1.8 milestone Aug 19, 2016
@bradfitz bradfitz self-assigned this Aug 19, 2016
@sajal
Copy link

sajal commented Sep 16, 2016

I ran into this issue today. My use case is such where for each test I setup my own transport and http.Client, perform a request, then let the transport/client run out of scope, never to be used again. My application was running out of file descriptors and digging deeper brought me here.

Code to reproduce issue: https://gist.github.com/sajal/cada559fea365fc2f7468a6e40e82e4b
Tested on go version go1.7 linux/amd64

With http2 disabled(GODEBUG=http2client=0), this does not cause in FD leak, but with http2 enabled, it holds onto the connection for ever, does not matter if the client falls out of scope, or if IdleConnTimeout has passed.

sajal@sajal-lappy:~$ go version
go version go1.7 linux/amd64
sajal@sajal-lappy:~$ go run 16808.go https://google.com/ #Running in http/2 mode
2016/09/17 01:59:45 HTTP/2.0
2016/09/17 01:59:45 COMMAND    PID  USER   FD   TYPE    DEVICE SIZE/OFF      NODE NAME
16808   253772 sajal  cwd    DIR     252,1    20480   6946818 /home/sajal
16808   253772 sajal  rtd    DIR     252,1     4096         2 /
16808   253772 sajal  txt    REG     252,1  3791309  12465293 /tmp/go-build656141105/command-line-arguments/_obj/exe/16808
16808   253772 sajal  mem    REG     252,1  1840928   7475996 /lib/x86_64-linux-gnu/libc-2.19.so
16808   253772 sajal  mem    REG     252,1   141574   7475124 /lib/x86_64-linux-gnu/libpthread-2.19.so
16808   253772 sajal  mem    REG     252,1   149120   7475126 /lib/x86_64-linux-gnu/ld-2.19.so
16808   253772 sajal    0u   CHR    136,73      0t0        76 /dev/pts/73
16808   253772 sajal    1u   CHR    136,73      0t0        76 /dev/pts/73
16808   253772 sajal    2u   CHR    136,73      0t0        76 /dev/pts/73
16808   253772 sajal    3u  IPv4 917612799      0t0       TCP 192.168.5.50:52719->sc-in-f139.1e100.net:https (ESTABLISHED)
16808   253772 sajal    4u  0000       0,9        0      8562 anon_inode
16808   253772 sajal    5r   CHR       1,9      0t0      1034 /dev/urandom
16808   253772 sajal    7r  FIFO       0,8      0t0 917612847 pipe
16808   253772 sajal    9r  FIFO       0,8      0t0 917612848 pipe

2016/09/17 01:59:51 COMMAND    PID  USER   FD   TYPE    DEVICE SIZE/OFF      NODE NAME
16808   253772 sajal  cwd    DIR     252,1    20480   6946818 /home/sajal
16808   253772 sajal  rtd    DIR     252,1     4096         2 /
16808   253772 sajal  txt    REG     252,1  3791309  12465293 /tmp/go-build656141105/command-line-arguments/_obj/exe/16808
16808   253772 sajal  mem    REG     252,1  1840928   7475996 /lib/x86_64-linux-gnu/libc-2.19.so
16808   253772 sajal  mem    REG     252,1   141574   7475124 /lib/x86_64-linux-gnu/libpthread-2.19.so
16808   253772 sajal  mem    REG     252,1   149120   7475126 /lib/x86_64-linux-gnu/ld-2.19.so
16808   253772 sajal    0u   CHR    136,73      0t0        76 /dev/pts/73
16808   253772 sajal    1u   CHR    136,73      0t0        76 /dev/pts/73
16808   253772 sajal    2u   CHR    136,73      0t0        76 /dev/pts/73
16808   253772 sajal    3u  IPv4 917612799      0t0       TCP 192.168.5.50:52719->sc-in-f139.1e100.net:https (ESTABLISHED)
16808   253772 sajal    4u  0000       0,9        0      8562 anon_inode
16808   253772 sajal    5r   CHR       1,9      0t0      1034 /dev/urandom
16808   253772 sajal    7r  FIFO       0,8      0t0 917613464 pipe
16808   253772 sajal    9r  FIFO       0,8      0t0 917613465 pipe

sajal@sajal-lappy:~$ GODEBUG=http2client=0 go run 16808.go https://google.com/ #Running in http/1.1 mode
2016/09/17 02:00:09 HTTP/1.1
2016/09/17 02:00:09 COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
16808   253847 sajal  cwd    DIR  252,1    20480   6946818 /home/sajal
16808   253847 sajal  rtd    DIR  252,1     4096         2 /
16808   253847 sajal  txt    REG  252,1  3791309  12465294 /tmp/go-build872584081/command-line-arguments/_obj/exe/16808
16808   253847 sajal  mem    REG  252,1  1840928   7475996 /lib/x86_64-linux-gnu/libc-2.19.so
16808   253847 sajal  mem    REG  252,1   141574   7475124 /lib/x86_64-linux-gnu/libpthread-2.19.so
16808   253847 sajal  mem    REG  252,1   149120   7475126 /lib/x86_64-linux-gnu/ld-2.19.so
16808   253847 sajal    0u   CHR 136,73      0t0        76 /dev/pts/73
16808   253847 sajal    1u   CHR 136,73      0t0        76 /dev/pts/73
16808   253847 sajal    2u   CHR 136,73      0t0        76 /dev/pts/73
16808   253847 sajal    4u  0000    0,9        0      8562 anon_inode
16808   253847 sajal    5r   CHR    1,9      0t0      1034 /dev/urandom
16808   253847 sajal    7r  FIFO    0,8      0t0 917625659 pipe
16808   253847 sajal    9r  FIFO    0,8      0t0 917625660 pipe

2016/09/17 02:00:15 COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
16808   253847 sajal  cwd    DIR  252,1    20480   6946818 /home/sajal
16808   253847 sajal  rtd    DIR  252,1     4096         2 /
16808   253847 sajal  txt    REG  252,1  3791309  12465294 /tmp/go-build872584081/command-line-arguments/_obj/exe/16808
16808   253847 sajal  mem    REG  252,1  1840928   7475996 /lib/x86_64-linux-gnu/libc-2.19.so
16808   253847 sajal  mem    REG  252,1   141574   7475124 /lib/x86_64-linux-gnu/libpthread-2.19.so
16808   253847 sajal  mem    REG  252,1   149120   7475126 /lib/x86_64-linux-gnu/ld-2.19.so
16808   253847 sajal    0u   CHR 136,73      0t0        76 /dev/pts/73
16808   253847 sajal    1u   CHR 136,73      0t0        76 /dev/pts/73
16808   253847 sajal    2u   CHR 136,73      0t0        76 /dev/pts/73
16808   253847 sajal    4u  0000    0,9        0      8562 anon_inode
16808   253847 sajal    5r   CHR    1,9      0t0      1034 /dev/urandom
16808   253847 sajal    6r  FIFO    0,8      0t0 917617532 pipe
16808   253847 sajal    8r  FIFO    0,8      0t0 917617533 pipe

sajal@sajal-lappy:~$ 

@sajal
Copy link

sajal commented Sep 16, 2016

Also to add, for my usecase the workaround is to defer transport.CloseIdleConnections() so when the function returns it releases the FD(s).

@bradfitz
Copy link
Contributor Author

@sajal, that's not just the workaround; that's what you should always do when letting a Transport go out of scope.

But this still needs to be fixed.

gopherbot pushed a commit to golang/net that referenced this issue Sep 30, 2016
Tests will be in the go repo's net/http package when this
package is re-bundled into std.

Updates golang/go#16808 (fixes after bundle into std)

Change-Id: Iad31dc120bc008b1e9679bf7b2b988aac9c893c8
Reviewed-on: https://go-review.googlesource.com/30075
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Sep 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants