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

Potential cache/throttle race conditions in Connector._resolve_host with traces #4013

Closed
ojii opened this issue Aug 29, 2019 · 0 comments · Fixed by #4014

Comments

@ojii
Copy link
Contributor

commented Aug 29, 2019

Long story short

If traces are used in TCPConnector._resolve_host the context switch introduced by awaiting their trace API calls can lead to various race conditions.

For example the DNS cache hit test may evaluate True but by the time traces is done it may already be gone again.

The same is true for the throttling logic where between checking that the key is already throttled and then accessing that key the key may already be popped.

Similarly in the opposite case of the above, with traces enabled, the code might override an already set throttled event

Steps to reproduce

See my branch

In the tests I mess with the caches from the traces directly to simulate the effects for simplicity.

@ojii ojii referenced this issue Aug 29, 2019
0 of 5 tasks complete

@helpr helpr bot added pr-available pr-rejected and removed pr-available labels Aug 29, 2019

asvetlov added a commit that referenced this issue Aug 31, 2019

@helpr helpr bot added pr-merged and removed pr-rejected labels Aug 31, 2019

asvetlov added a commit that referenced this issue Aug 31, 2019
[3.6] Fix #4013 _resolve_host race conditions (#4014)
(cherry picked from commit 010caab)

Co-authored-by: Jonas Obrist <ojiidotch@gmail.com>
asvetlov added a commit that referenced this issue Aug 31, 2019
[3.6] Fix #4013 _resolve_host race conditions (#4014) (#4030)
(cherry picked from commit 010caab)

Co-authored-by: Jonas Obrist <ojiidotch@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.