# Help diagnosing ERROR 2013 (HY000): Lost connection to MySQL server during query

**URL:** <https://forums.percona.com/t/help-diagnosing-error-2013-hy000-lost-connection-to-mysql-server-during-query/6923>\
**Category:** Percona Server for MySQL 8.0\
**Created:** [March 25, 2019, 1:34pm UTC](https://forums.percona.com/t/help-diagnosing-error-2013-hy000-lost-connection-to-mysql-server-during-query/6923 "2019-03-25T13:34:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SullyBeck](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@SullyBeck](https://forums.percona.com/u/SullyBeck)\
**Post date:** [March 25, 2019, 1:34pm UTC](https://forums.percona.com/t/help-diagnosing-error-2013-hy000-lost-connection-to-mysql-server-during-query/6923/1 "2019-03-25T13:34:38Z")

</div>

I’m running percona 8.0.15 on RHEL6 (fully patched).

I have a large database and I’m trying to do a query (fairly complex and expected to take a while). It runs for (exactly?) 300 seconds and then the client exits with:

ERROR 2013 (HY000): Lost connection to MySQL server during query

Nothing shows up in any logs (either system or MySQL logs). After a number of searches, I have tried increasing several parameters including:

net\_read\_timeout=600  
net\_write\_timeout=180  
wait\_timeout=86400  
interactive\_timeout=86400  
max\_allowed\_packet=8192M  
max\_execution\_time=600000

and none of them modified the behavior (i.e. they all continued to exit at 300s). The load on the server does not seem to be seriously impacted (i.e. CPU and memory remain more or less contant).

I’ve looked through all of the variables and do not see any timeout that is set to 300s/5min, so at this point, I’m just looking for pointers on where to look next.

Thanks

---

<div class="post-metadata">

**Author:** ![mauritz72](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@mauritz72](https://forums.percona.com/u/mauritz72)\
**Post date:** [October 17, 2019, 10:17am UTC](https://forums.percona.com/t/help-diagnosing-error-2013-hy000-lost-connection-to-mysql-server-during-query/6923/2 "2019-10-17T10:17:31Z")

</div>

Hi, I am experiencing the exact same error with our full and incremental backups.

I have tried increasing timeout values just as you have with no success.

This started happening when one of our tables containing BLOB column data grew from 80GB up to over 100GB in size.

The ‘Lost connection’ message occurs just after the copy of the table data for the large table, like this:

191013 07:20:35 \>\> log scanned up to (132055253021)  
191013 07:20:36 \>\> log scanned up to (132055253021)  
191013 07:20:36 [04] …done  
191013 07:20:37 \>\> log scanned up to (132055253021)  
Error: failed to execute query SET SESSION lock\_wait\_timeout=31536000: Lost connection to MySQL server during query

If we exclude the large table from the backup everything works as before.

What we see when we include the large table is that the SQL connection created by the xtrabackup client is stuck on sleep and never disconnects, even though the xtrabackup client exits with the ‘Lost connection to MySQL server during query’ message.

Did you find a solution to your problem?

---

<div class="post-metadata">

**Author:** ![lorraine.pocklington](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lorraine.pocklington/32/37_2.png) [@lorraine.pocklington](https://forums.percona.com/u/lorraine.pocklington)\
**Post date:** [October 18, 2019, 7:44am UTC](https://forums.percona.com/t/help-diagnosing-error-2013-hy000-lost-connection-to-mysql-server-during-query/6923/3 "2019-10-18T07:44:00Z")

</div>

As a matter of interest, is your very large table using the INNODB storage engine?  
I ask because for MYISAM (and other storage engines), then Percona Xtrabackup will take a table lock for backup.  
Other than that, though, please provide versions of the software and info about the environment - I may move you to a new thread.

---

<div class="post-metadata">

**Author:** ![Francis\_Fish](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/francis_fish/32/14231_2.png) [@Francis\_Fish](https://forums.percona.com/u/Francis_Fish)\
**Post date:** [December 18, 2023, 11:49am UTC](https://forums.percona.com/t/help-diagnosing-error-2013-hy000-lost-connection-to-mysql-server-during-query/6923/4 "2023-12-18T11:49:24Z")

</div>

Hi there

Did you resolve this? We’ve just had a backup that ran for years start failing with this error about a week ago.

We’re running 5.7 and 2.4.28 in Docker.

I thought it might be something to do with table size, and we had a huge table that was a temporary backup that I got rid of.

It’s worked once since I got rid of the big table but it’s gone back to failing again

Any clues gratefully received

Thank you

---

<div class="post-metadata">

**Author:** ![siyue\_nehc](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/siyue_nehc/32/11742_2.png) [@siyue\_nehc](https://forums.percona.com/u/siyue_nehc)\
**Post date:** [May 27, 2024, 10:38am UTC](https://forums.percona.com/t/help-diagnosing-error-2013-hy000-lost-connection-to-mysql-server-during-query/6923/5 "2024-05-27T10:38:08Z")

</div>

May I ask if you have found a solution？
