1

Flask with SQLAlchemy Flask==0.10.1 SQLAlchemy==1.0.8

In production after a lot of usages (connection) we are getting this error. After that restarting the server helps, what will be the permanent solution

OperationalError: (psycopg2.OperationalError) server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\

Similarly, we are creating a scoped session, we are doing session.close()

I tried Null Pool which doesn't help

Any ideas on that?

Relevant finding Is it odd that my SQLAlchemy MySQL connection always ends up sleeping?

Handle mysql restart in SQLAlchemy

Shankar
  • 846
  • 8
  • 24

1 Answers1

0

We need to handle it in SQLAlchemy Dealing Disconnect

https://docs.sqlalchemy.org/en/latest/core/pooling.html#dealing-with-disconnects

Shankar
  • 846
  • 8
  • 24