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

net/http: http2 addConnIfNeeded with the same key multiple. #42762

Closed
xiekeyi98 opened this issue Nov 21, 2020 · 6 comments
Closed

net/http: http2 addConnIfNeeded with the same key multiple. #42762

xiekeyi98 opened this issue Nov 21, 2020 · 6 comments

Comments

@xiekeyi98
Copy link

xiekeyi98 commented Nov 21, 2020

Before, I file the issue: #42662 .
But I closed it because I think it may something wrong with the server.

I'm trying to make why the HTTP client retries again and again and why the fd get high.

I compiled with this commit: xiekeyi98@a8c91a2

and the debug message makes me confused.

 GODEBUG=http2debug=1 ./go run ./main2.go 2>&1 | grep "keyixie"
2020/11/22 03:27:55 keyixie t1 TLS NextProto if.
2020/11/22 03:27:55 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:55 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie addConnIfNeeded [key=firmacct.html5.qq.com:443]
2020/11/22 03:27:56 keyixie [key=firmacct.html5.qq.com:443]

I was wondering if someone may help me to make it clear? Why it retry with the same key(firmacct.html5.qq.com:443) again and again?
Thanks a lot!

@xiekeyi98
Copy link
Author

My test code: https://play.golang.org/p/ehSaYRrnW99

@xiekeyi98 xiekeyi98 changed the title net/http: http2 addConnIfNeeded the same key multiple. net/http: http2 addConnIfNeeded with the same key multiple. Nov 23, 2020
@networkimprov
Copy link

cc @fraenkel

@fraenkel
Copy link
Contributor

It will be more obvious if you turn on http2 debug. You are making an http2 request which fails. The default behavior is to retry until certain conditions hold true.
In your case, the timeout will stop the retry.

@xiekeyi98
Copy link
Author

It will be more obvious if you turn on http2 debug. You are making an http2 request which fails. The default behavior is to retry until certain conditions hold true.
In your case, the timeout will stop the retry.

Thank you for your kindly help. I would like to know if it is necessary to retry with more than one handle, the default client timeout is unlimited, which causes the handles to be easily exhausted.

@fraenkel
Copy link
Contributor

Again, look at what is actually happening. You are sending a request but the reply is an immediate RST_STREAM with REFUSED_STREAM.

Per 8.1.4 of the http2 spec:
Requests that have not been processed have not failed; clients MAY
automatically retry them, even those with non-idempotent methods.

@xiekeyi98
Copy link
Author

xiekeyi98 commented Nov 25, 2020 via email

@golang golang locked and limited conversation to collaborators Nov 25, 2021
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

4 participants