Closed ebreton closed 5 years ago
Thanks!
For anyone else who is having the same issue, suggested solution also works for MySql Databases. Error showing up as: 500 Internal Server Error ERROR
Solution: add a pool_pre_ping=True argument to the SQLAlchemy create engine line:
engine = create_engine("mysql+pymysql://user:pw@host/db", pool_pre_ping=True)
Describe the bug
The application returns (randomly) 500 errors.
When looking at the logs, we can see some OperationError occuring:
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) server closed the connection unexpectedly
Following the link at the end of the traceback, we have the following information from SQLAlchemy web site:
Here is the full traceback
Expected behavior No 500 returned to the end user. Connection refreshed if needed.
Additionnal context The application runs within a container, following the setup from https://dockerswarm.rocks