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: race between operations on maxClientStreamID and inGoAway. #51309

Closed
doujiang24 opened this issue Feb 22, 2022 · 5 comments
Closed
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@doujiang24
Copy link
Contributor

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

$ go version
go version go1.17.2 darwin/amd64

Does this issue reproduce with the latest release?

yeah, maybe. I haven't reproduced it yet.
Just found this issue based on code.

race may happen on such a flow:


 fields                                 write goroutine                       read goroutine

                                                                         1. read(false), in processHeaders
inGoAway
                                       2. set to true, in goAway
----------------------------------------------------------
                                       3. read(old), in scheduleFrameWrite 
maxClientStreamID
                                                                        4. set(a new), in processHeaders

The server may have already processed the new request while the client got the old stream id in the GoAway frame,
and the client will retry the new request again.

Yeah, the race is very very small, but I think it indeed exists in theory.
eg. these three things happen at the same time:

  1. server received a request header,
  2. server got a signal to start graceful stop,
  3. an OS schedule on the read goroutine between operation 1 and operation 4(make it is long enough time).

Or, do I misunderstand the code?
Thanks!

@mengzhuo
Copy link
Contributor

Can you build your exmaple code with -race ?
https://go.dev/doc/articles/race_detector

@mengzhuo mengzhuo added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 22, 2022
@mengzhuo mengzhuo changed the title net/http: server: maybe a little race between operations on maxClientStreamID and inGoAway. net/http: race between operations on maxClientStreamID and inGoAway. Feb 22, 2022
@doujiang24
Copy link
Contributor Author

@mengzhuo Thanks for your reply.
In my opinion, it's hard to build a reproducible example even with -race.

I think the key point is:
we assume there may be a long time between these two lines, eg. an OS schedule that -race can not simulate.
https://github.com/golang/go/blob/master/src/net/http/h2_bundle.go#L5525-L5565

@ianlancetaylor
Copy link
Contributor

CC @neild to see if there is a race in the net/http code.

@doujiang24
Copy link
Contributor Author

@neild Could you please take a look at this issue? Thanks.

@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Dec 26, 2022
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants