-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Can't recover after restarting MySQL #4945
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
Comments
This is a bug in the PyMySQL driver because it is an InternalError. There are issues that seem to discuss this but it's not clear what behavior PyMySQL has right now, there is PyMySQL/PyMySQL#526 as well as sidorares/node-mysql2#510 , and it's not clear if you are seeing a new behavior is this is a regression in a newer PyMySQL or a fxed bug in an older version, since I don't know what PyMySQL version you are on. SQLAlchemy detects a "disconnect" based on the type of error raised and the logic for pymysql does not currently expect an InternalError because the driver is not supposed to raise those. nothing has changed in SQLAlchemy so there is no regression here, unless you can provide a reproducing test case that reproduces the error on the given version and does not reproduce it on a specific former version, with no changes in anything else. advice here would be to restore the previous version of PyMySQL before your upgrade and if it is an older version, to report a regression at https://github.com/PyMySQL/PyMySQL/issues/ |
We use pymysql version 0.9.3 (Dec 18, 2018). It's a little strange, because no fresh upgrade were done on the driver. I'll try to investigate. |
if PyMySQL devs confirm this is going to stay as InternalError (which would be very unusual), we could add this to the list of "disconnect" exceptions, however, they should fix this on their end. You can work around this by providing a disconnect handler for this specific error, if you are really in a bind, see the example at https://docs.sqlalchemy.org/en/13/core/events.html?highlight=handle_error#sqlalchemy.events.ConnectionEvents.handle_error . basically is_disconnect indicates that the connection pool will refresh itself. Or, you can use NullPool to disable connection pooling, or set pool_recycle to a very low number of seconds: https://docs.sqlalchemy.org/en/13/core/pooling.html#pool-setting-recycle |
there are already some buggy errors that we are testing for in both pymysql and mysqldb so will add this. |
Mike Bayer has proposed a fix for this issue in the master branch: Detect PyMySQL connection was killed https://gerrit.sqlalchemy.org/1575 |
Mike Bayer has proposed a fix for this issue in the rel_1_3 branch: Detect PyMySQL connection was killed https://gerrit.sqlalchemy.org/1576 |
Added "Connection was killed" message interpreted from the base pymysql.Error class in order to detect closed connection, based on reports that this message is arriving via a pymysql.InternalError() object which indicates pymysql is not handling it correctly. Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e References: PyMySQL/PyMySQL#816 Fixes: #4945 (cherry picked from commit 31a66b5)
Added "Connection was killed" message interpreted from the base pymysql.Error class in order to detect closed connection, based on reports that this message is arriving via a pymysql.InternalError() object which indicates pymysql is not handling it correctly. Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e References: PyMySQL/PyMySQL#816 Fixes: sqlalchemy#4945
Hi,
I use the lastest stable version of SQLAlchemy (1.3.10) in a production system, and lately I noticed that restarting the MySQL server cause big troubles in our application. SQLAlchemy cannot recover until we restart the WSGI application.
This seems to be a regression, because I can't remember having this issue earlier.
Additional informations
We are using the pymysql driver. The server version is Mariadb 10.2.27
Here is the errlog:
The text was updated successfully, but these errors were encountered: