-
Notifications
You must be signed in to change notification settings - Fork 219
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
fix: HTTPTransport.Flush panic and data race #140
Conversation
There are no automated tests covering the Would love some ideas in that regard. Thinking of testing some properties of Flush, like:
|
b0f8cfa
to
c8b5435
Compare
I've included a few tests to exercise |
c8b5435
to
4277850
Compare
The ConcurrentSendAndFlush test reveals a data race in the HTTPTransport implementation.
Rewrite HTTPTransport internals to remove a data race and occasional panics. Prior to this, HTTPTransport used a `sync.WaitGroup` to track how many in-flight requests existed, and `Flush` waited until the observed number of in-flight requests reached zero. Unsynchronized access to the WaitGroup lead to panics (reuse before wg.Wait returns) and data races (undefined order of wg.Add and wg.Wait calls). The new implementation changes the `Flush` behavior to wait until the current in-flight requests are processed, inline with other SDKs and the Unified API.
4277850
to
da6caef
Compare
Added more code comments describing how the mechanism works and what invariants are considered. Renamed and reorganized test code based on code review in person with @bruno-garcia. Thanks @bruno-garcia!!! |
Rewrite HTTPTransport internals to remove a data race and occasional
panics.
Prior to this, HTTPTransport used a
sync.WaitGroup
to track how manyin-flight requests existed, and
Flush
waited until the observed numberof in-flight requests reached zero.
Unsynchronized access to the WaitGroup lead to panics (reuse before
wg.Wait returns) and data races (undefined order of wg.Add and wg.Wait
calls). See #103 (comment), #103 (comment) and #103 (comment).
The new implementation changes the
Flush
behavior to wait until thecurrent in-flight requests are processed, inline with other SDKs and the
Unified API.
Fixes #103.