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