drush cr crashes a site running in AWS Elastic Beanstalk

Created on 9 November 2021, over 2 years ago
Updated 5 March 2024, 3 months ago

Problem/Motivation

After upgrading Drupal from 8.9 to 9.2, when I clear cache with `drush cr` from an AWS EC2 instance for the site running in EB instance, the site in EB crashes. It is our practice -- I suppose many Drupal sites in AWS would be similar -- to run drush commands from EC2 instance for sites in EB.

I believe this change ( https://www.drupal.org/node/3080612 β†’ ) caused the issue. While one might say it is an edge case with AWS environment, I can imagine there are a lot of Drupal sites running in AWS EB.

For Drupal 9, the problem is that `cache_container` DB table has the entry for service_container, where `app.root` is set to the system's path, which is different between EC2 and EB; /var/www/vhosts/example.com/httpdocs/web vs. /var/app/current/web in my case.

The temporary workaround that may be of help to others with the same issue is to put these in settings.local.php of the codebase in EC2, so that running drush commands from EC2 won't update `cache_container` DB table that's shared between EC2 and EB sites.

// Change the backend of cache.container to avoid caching the service container.
// Needed to avoid caching the webroot, which is different on the master instance and EB.
// (overrides $defaultBootstrapContainerDefinition in DrupalKernel)
$settings['bootstrap_container_definition'] = [
  'parameters' => [],
  'services' => [
    'database' => [
      'class' => 'Drupal\Core\Database\Connection',
      'factory' => 'Drupal\Core\Database\Database::getConnection',
      'arguments' => ['default'],
    ],
    'cache.container' => [
      'class' => 'Drupal\Core\Cache\NullBackend',
      'arguments' => ['container'],
    ],
    'cache_tags_provider.container' => [
      'class' => 'Drupal\Core\Cache\DatabaseCacheTagsChecksum',
      'arguments' => ['@database'],
    ],
  ],
];

Steps to reproduce

Run `drush cr` from AWS EC2 for a site in EB on a Drupal 9 site.

Proposed resolution

Either revert the change that brought out the issue or make `app.root` overridable in settings.php

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component
BootstrapΒ  β†’

Last updated 9 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States Ki

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    @Ki, Thank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.

    There has been no discussion here for two years so I am checking to see if this is still a problem.

    If you are no longer having this issue, ,leave a comment describing how you fixed it, as it may help others with the same issue.

    Since we need more information to move forward with this issue, I am setting the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.69.0 2024