[Sqlalchemy-tickets] Issue #4046: AttributeError: 'Connection' object has no attribute '_Connection
Brought to you by:
zzzeek
From: Daniel B. <iss...@bi...> - 2017-08-18 09:27:44
|
New issue 4046: AttributeError: 'Connection' object has no attribute '_Connection__connection' https://bitbucket.org/zzzeek/sqlalchemy/issues/4046/attributeerror-connection-object-has-no Daniel Birnstiel: I am currently receiving the exception mentioned in the title on a production deployment of a flask application using SQLAlchemy. This issue has happened before (closed in #1246 and #2317), but appears to have resurfaced again. Some info about my environment: ``` #!bash % py --version Python 3.4.3 % pip freeze | grep SQLAlchemy SQLAlchemy==1.1.4 ``` Database is an RDS instance on AWS using psycopg2==2.6.2 as a driver. Full exception log: https://gist.github.com/Birne94/e6e7ba91d44a680ba09419f7aa9f5705 (also attached to this report) The exception log shows two different exceptions happening: * At first the server closes a connection, most likely due to a restart on the side of the database server. The query fails, page errors. I have a custom exception handler which will rollback the failed database session. Since this was a simple SELECT, I guess this is not needed (right?). * Further access to the database fails with the exception mentioned in the title. As mentioned above, the failed transation was rolled back so there shouldn't be any issue with this one still existing. Again, the query was a simple select which should not start any transaction. After restarting the server (uwsgi), everything went back to normal. Unfortunately, it was a priority to get the server up and running again, so I was unable to further investigate the issue by attaching a debugger. I would guess that SQLAlchemy should be able to handle closed connections and be able to reconnect automatically. If this is not the case, is there anything I can do to detect operations on an invalid connection and perform a manual reconnect? Thanks for reading. |