Description of problem:
SQLAlchemy release 0.8.7 fixes an issue in the MySQL dialect, where a "commands out of sync" exception may not be interpreted correctly as a "database disconnect" situation. The "commands out of sync" exception in MySQLdb is often a non-recoverable situation, and typically is the result of inappropriate concurrent access on a single connection object. Because the connection is often unusable when this error occurs, we treat this as a disconnect, throwing out the connection and also refreshing the remaining connections stored in the connection pool.
The fix in issue #3101 adds ProgrammingError to the list of base exceptions searched for the given error code (2014).
SQLAlchemy issue: https://bitbucket.org/zzzeek/sqlalchemy/issue/3101
ran the following python test code to verify:
from sqlalchemy import create_engine
from sqlalchemy import exc
self.engine = create_engine(
connection = self.engine.connect()
raw_conn = connection.connection
# use raw commands to place the connection into
# a state where additional queries are not allowed
raw_result = raw_conn.use_result()
# use the SQLAlchemy connection to try to execute a statement;
# this raises ProgrammingError on MySQLdb
# (usually raises OperationalError on others)
connection.execute, "select 1"
# the engine and connection pool is flushed totally,
# and on subsequent use reconnects and works again
connection.scalar("select 1"), 1
if __name__ == '__main__':
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.