garncarz / nogamespy-vietcong

Vietcong 1 multiplayer game support
https://vietcong1.eu
GNU Affero General Public License v3.0
18 stars 2 forks source link

Tweak DB pooling #17

Open garncarz opened 6 years ago

garncarz commented 6 years ago

Trying to solve #15.

garncarz commented 6 years ago

create_engine(..., pool_pre_ping=True) didn't prove helpful.

garncarz commented 6 years ago

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.

garncarz commented 6 years ago

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.

garncarz commented 6 years ago

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.