Diagnostics 2013 Lost Connection with MySQL

I am using SQLAlchemy with two MySQL databases. One is my development database, hosted locally on my machine, and the other is the MySQL server provided by ClearDB on Heroku for production.

I have a long database session when it performs a synchronization operation with another service. On my local machine, this ends up fine, but in production I get an error (2013, "Lost connection to MySQL server during query").

I read other posts that say it can be either the request size is too large or the pool update variable that needs to be configured. I donโ€™t think the transaction payload is relatively large and setting the pool_recycle variable when calling SQLAlachemy create_engine did not seem to work.

Has anyone else encountered this problem or were able to help me narrow down the cause of this error - it seems like a trick and I'm not sure where to go from here.

As indicated in the comments, both systems return the same values โ€‹โ€‹for select @@interactive_timeout, @@wait_timeout : 28800, 28800.

thanks

+6
source share
1 answer

Despite the fact that the two databases seem to use the same timeouts and configuration, as a rule. This turned out to be a timeout executed elsewhere using ClearDB.

ClearDB monitors connections and kills them when they are open for more than a minute. Initially, I could not find this documentemnted .

The fix actually set pool_recycle to pool_recycle=60 when creating the engine. My previous attempt at this, I used an arbitrary number (because I did not know the ClearDB timeout) above this.

+2
source

Source: https://habr.com/ru/post/1012423/


All Articles