-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
DNSCache BUG #2620
Comments
Well spotted, this is a corner case tha was not take into consideration. However, the outcome of your test matches with the desired implementation that considered a full round robin between all of the ongoing tasks to create connections, indeed the addrs used at the end of your test are in terms of how many, the same per addr. The fix should still meet IMHO the requirement which try to use as a first option for the incomming task the next addr avoiding use the same addr and using the list only when some host is unreachable. |
Fixed by #2621 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
(please help me to choose good subject)
It's not easy to explain why this bug happens. I will try:
Here is current code (cutted):
another place (very simplified):
Suppose now, that
_create_direct_connection
is run in parallel. Sincedns_cache.next_addrs()
returnsislice
which points tocycle
which points to internal state, it's state IS REUSED in parallel instances of_create_direct_connection
. This lead to wrong results returned byislice
.And now, let's try to reconstruct situation in test program:
and run it:
As you can see, it's not what author expect! No one instance received a,b,c and d!
How did I come to this bug? I was just doing parallel requests to Dropbox. The resolver gives me IPv6 address as well as IPv4. But my system does not have IPv6 and so
connect()
reports EUNREACH for IPv6 addresses. In my case sometimesislice
gave only IPv6 addresses! and whole request failed.How to cure?
simpliest solution is to return
list(islice(....))
Except for my problem, there is two more:
DNSCace::remove()
andDNSCache.clean()
since the operate on "shared between green threads" state.The text was updated successfully, but these errors were encountered: