Problem/Motivation

I've been setting up a hobby site using Drupal CMS on cheap shared hosting which has composer and SSH access (using Hostinger). I ran into a problem because the hosts default wait_timeout on database connections is 20 seconds. This meant I was unable to install any modules or run updates from Drupal.org because the DB connection is dropped while we're off doing composer commands. When the kernel terminates we crash because the DB connection is gone and we're unable to release the locks.

Steps to reproduce

Set wait_timeout to a short time and try to use package manager.

Proposed resolution

A few thoughts:

  • Should we have a warning or error on system status if we find this to be short?
  • Can we implement a re-connection - ala #3494917: Database ping, close, and reconnect capabilities - these timeouts are problematic for more than just package manager
  • Could package manager issue SQL commands to increase the timeout (not sure I like this solution because it is likely to be DB dependent).

Remaining tasks

User interface changes

TBD

Introduced terminology

API changes

TBD

Data model changes

TBD

Release notes snippet

Issue fork drupal-3511967

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexpott created an issue. See original summary.

alexpott’s picture

I worked around the problem by adding

$databases['default']['default']['init_commands'] = [
  'waits' => 'SET SESSION wait_timeout=28800',
  'wait 2' => 'SET SESSION interactive_timeout=28800',
];

to settings.php but I don't think the target audience is going to find that an easy solution.

phenaproxima’s picture

Is the wait_timeout stuff standard to all database types supported by core? If so, I don't think I see any problem with Package Manager sending those commands when the kernel boots up.

pameeela’s picture

phenaproxima’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.