<p>If a MySQL connection drops in the middle of a request, then that will either cause a PHP fatal error (that will end the request entirely) or cause an exception to be thrown.</p>

<p>If the exception isn't handled, then the request will end as well.  If it is caught, it can be gracefully handled and the request can continue. The remaining part of the request might attempt a new database connection, but it will not attempt to re-execute the SQL on the previously dropped MySQL connection. It has moved on.</p>

CC BY-SA 3.0
2015-09-29T21:44:45.397Z
2015-09-29T21:44:45.397Z
Brad Bell
<p>We have a customer using a cheap managed hosting provider, and their MySQL server very aggressively times out and drops the connection. </p>

<p>I wonder if this could be causing us troubles as outlined here: <a href="https://craftcms.stackexchange.com/questions/11365/massive-template-cache-cleaning-tasks-always-get-stuck">Massive template cache cleaning tasks always get stuck</a></p>

<p>Does Craft attempt to reconnect to MySQL if the connection drops halway through a request? </p>

<database><hosting><mysql>
Will craft attempt to reconnect to MySQL if the connection drops?
# Will craft attempt to reconnect to MySQL if the connection drops?

(Asked by: username_0 on 2015-09-11)

We have a customer using a cheap managed hosting provider, and their MySQL server very aggressively times out and drops the connection.

I wonder if this could be causing us troubles as outlined here: [Massive template cache cleaning tasks always get stuck](https://craftcms.stackexchange.com/questions/11365/massive-template-cache-cleaning-tasks-always-get-stuck)

Does Craft attempt to reconnect to MySQL if the connection drops halway through a request?

**Tags:** database, hosting, mysql

---

## 1 answers

### Answer by username_1 on 2015-09-29. Score: 2 | Accepted answer

If a MySQL connection drops in the middle of a request, then that will either cause a PHP fatal error (that will end the request entirely) or cause an exception to be thrown.

If the exception isn't handled, then the request will end as well. If it is caught, it can be gracefully handled and the request can continue. The remaining part of the request might attempt a new database connection, but it will not attempt to re-execute the SQL on the previously dropped MySQL connection. It has moved on.


---

