Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-29T21:44:45.397Z
Answers.LastActivityDate: 2015-09-29T21:44:45.397Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Tags: <database><hosting><mysql>
Title: Will craft attempt to reconnect to MySQL if the connection drops?
ThreadText: # 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.
  
  
  ---
  
  