Logging service not available for memcache during boot

Created on 13 October 2024, 6 months ago

Problem/Motivation

I'm experiencing two errors when attempting to ensureBinDeletionTimeIsSet while constructing Drupal's service container.

  • Memcache encouters an error during a set() call.
  • The Memcached driver attempts to log the error but fails since the service container is still being built.
[10-Oct-2024 05:10:48 UTC] Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in /var/www/html/docroot/core/lib/Drupal.php on line 169 #0 /var/www/html/docroot/core/lib/Drupal.php(197): Drupal::getContainer()
#1 /var/www/html/docroot/core/lib/Drupal/Core/Logger/LoggerChannelTrait.php(39): Drupal::service()
#2 /var/www/html/docroot/modules/contrib/memcache/src/Driver/MemcachedDriver.php(24): Drupal\memcache\Driver\DriverBase->getLogger()
#3 /var/www/html/docroot/modules/contrib/memcache/src/Invalidator/MemcacheTimestampInvalidator.php(59): Drupal\memcache\Driver\MemcachedDriver->set()
#4 /var/www/html/docroot/modules/contrib/memcache/src/Invalidator/TimestampInvalidatorBase.php(44): Drupal\memcache\Invalidator\MemcacheTimestampInvalidator->writeTimestamp()
#5 /var/www/html/docroot/modules/contrib/memcache/src/Invalidator/MemcacheTimestampInvalidator.php(38): Drupal\memcache\Invalidator\TimestampInvalidatorBase->markAsOutdated()
#6 /var/www/html/docroot/modules/contrib/memcache/src/MemcacheBackend.php(489): Drupal\memcache\Invalidator\MemcacheTimestampInvalidator->invalidateTimestamp()
#7 /var/www/html/docroot/modules/contrib/memcache/src/MemcacheBackend.php(94): Drupal\memcache\MemcacheBackend->ensureBinDeletionTimeIsSet()
#8 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(81): Drupal\memcache\MemcacheBackend->__construct()
#9 /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(179): Drupal\Component\DependencyInjection\PhpArrayContainer->createService()
#10 /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php(576): Drupal\Component\DependencyInjection\Container->get()
#11 /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php(965): Drupal\Core\DrupalKernel->getCachedContainerDefinition()
#12 /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php(515): Drupal\Core\DrupalKernel->initializeContainer()
#13 /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php(739): Drupal\Core\DrupalKernel->boot()
#14 /var/www/html/docroot/index.php(19): Drupal\Core\DrupalKernel->handle()
#15 {main}

This issue seems intermittent so I suspect there is a problem with the memcache service (though it seems it can connect). However I can't see the log since the logging service isn't there to log it.

Worse, this results in a Fatal Error and kills the whole request.

Proposed resolution

  • Firstly it doesn't seem like memcache should fail because its logging service is not available. At the least, it should fail silently. A failed cache set should only result if further cache misses later on.
  • Perhaps there should be a fall back logging option such as PHP's error_log function.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.7

Component

Code

Created by

🇳🇿New Zealand Josh Waihi

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

Comments & Activities

Production build 0.71.5 2024