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

Don't reuse connections when StreamReader has an exception #339

Merged
merged 4 commits into from
Sep 17, 2018

Conversation

TimothyFitz
Copy link
Contributor

In our production environment, we occasionally experience connection timeouts that "stick" in the aiomysql Pool. Every subsequent connection acquired from the pool will fail on first use.

My production environment full traceback (with private code redacted): https://gist.github.com/TimothyFitz/2d929f907c4cad47a7c8da8e0944b19e

This PR adds a test to simulate our production failure by directly calling connection_lost on a connection in the free pool.

The pool code already checks for gracefully closed connection via _reader.at_eof(). The fix is to also check for _reader.exception().

I think #132 accidentally conflated two issues, and the fix identified there is needed in addition to pool recycling: #132 (comment)

Tested on:
(production) Ubuntu 16.04.5 LTS, Python 3.5.2, aiomysql 0.0.17 + this patch
(dev laptop) Ubuntu 18.04.1 LTS, Python 3.6.5, this PR (master + patch)

@codecov
Copy link

codecov bot commented Sep 12, 2018

Codecov Report

Merging #339 into master will increase coverage by 0.26%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #339      +/-   ##
==========================================
+ Coverage   92.91%   93.17%   +0.26%     
==========================================
  Files           9        9              
  Lines        1129     1129              
  Branches      161      161              
==========================================
+ Hits         1049     1052       +3     
+ Misses         56       54       -2     
+ Partials       24       23       -1
Impacted Files Coverage Δ
aiomysql/pool.py 96.83% <100%> (+1.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67b01a8...b19d816. Read the comment docs.

@terricain
Copy link
Collaborator

Looks good, great work :)

@terricain terricain merged commit e81f356 into aio-libs:master Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants