Open garncarz opened 6 years ago
create_engine(..., pool_pre_ping=True)
didn't prove helpful.
Unfortunately, changing sqlalchemy.pool.QueuePool
to sqlalchemy.pool.NullPool
also doesn't seem to help with issues like (pymysql.err.OperationalError) (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")
and (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')
. There's always a few (of both of them) every day.
It seems to be originating solely from ./app.py --master
, so if I move db_session.remove()
to the end of a request (instead of calling it first to clean the previous possibly "dirty" state), it could help releasing connections, not keeping them till timeout from the DB side.
Or no, there actually can be a dirty DB session state if a previous request wasn't somehow successful, so some cleaning should be done. But in that case I can expect the connection to fail on being time-outed, so I can ignore exceptions of that kind at that place.
Trying to solve #15.