MySQL wait_timeout

Component ID

2364137

Component name

MySQL wait_timeout

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

302

Component created

Component changed

Component body

This module intends to address the quite common "MySQL has gone away" error. Many shared, production MySQL servers set a rather low value for MySQL's wait_timeout parameter (e.g., 1 minute) and this is to be considered good practice as most connections to such servers are intended to generate HTTP responses as fast as possible.
On the other hand, Drupal may keep its MySQL connection idle for long durations for valuable purposes, such as running its cron job or running a Drush command: content import, link checking, reindexation..
The wait_timeout module is able to enforce wait_timeout in up to three different, optional contexts:

  • default: wait_timeout is enforced during hook_init
  • drush: wait_timeout is enforced (D6-specific: during hook_init) if Drush is detected
  • cron: wait_timeout is enforced (D6-specific: among the first invoked hook_cron()s) if cron.php or drush cron is detected.

This module does nothing until it is configured -- the following variables are to be enforced, typically in settings.php:

  • mysql_wait_timeout_enforce_default: TRUE to systematically enforce wait_timeout to mysql_wait_timeout_default_duration (in seconds)
  • mysql_wait_timeout_enforce_cron: TRUE to enforce wait_timeout to mysql_wait_timeout_cron_duration (in seconds) for cronjobs
  • mysql_wait_timeout_enforce_drush: TRUE to enforce wait_timeout to mysql_wait_timeout_drush_duration (in seconds) for Drush commands

For Drupal 6: install and enable the module to take into account the configuration above.
For Drupal 7: this project simply provides a file, to be included in settings.php, that takes the configuration above into account.