Page MenuHomePhabricator

"Lost connection to MySQL server during query" using pymysql on toolforge connecting to db replica
Closed, ResolvedPublic


I'm rewriting a tool and the new Python version is getting "(2013, 'Lost connection to MySQL server during query')" while the old tool has no issues. The query is very large, probably half a million rows

This is the code in question for the new Python version:

And the corresponding Perl code:

The error happens on line 16 of the paste of the Python code: cursor.execute. It doesn't even get to the fetchmany call. Here is the stack trace of the actual call (the line numbers don't line up with the paste because of imports):

The database connection happens here:

According to this mysql help article ( it's most likely the net_read_timeout variable, but I know that we can't adjust that globally.

Also the error is repeatable, on every run of the new tool, so it's not a network fluke or maintenance.

Event Timeline

I'm going to try replacing DictCursor with SSDictCursor and see if that helps.

Audiodude claimed this task.

That seems to have resolved the issue!