Fix connection leaks in dependencies by monkey patching gevent queues #656
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connection pools implemented using standard library queues can leak connections when a gevent timeout exception is raised. To avoid this gevent queues should be used rather than standard library queues.
We fixed this in baseplate.py Thrift pools, but there are still many such issues in dependencies. In some cases we can explicitly use a gevent queue, but in other cases we have to monkey patch.
Previously we did not monkey patch because it is unclear why gevent
patch_queue
andpatch_all
does not patch by default. I've raised an issue asking the gevent team about this, and also started canarying such a change in a Reddit service that was experiencing Kombu connection leaks. The service hasn't experienced any issues with the change so I'd like to merge it upstream.