Since 8.x-2.9, a site whose memcache server is unreachable can fail every request with:

Circular reference detected for service "module_handler", path: "module_handler -> cache.bootstrap -> logger.factory -> logger.syslog -> config.factory -> config.typed".

While an unreachable server should only mean the site runs without that cache, unfortunately the site, including drush status, is down until the memcache server comes back.

According to claude, the failure logging added in #3480143: Log connection failure is the cause:

  1. The bootstrap cache bin is created while the container is constructing module_handler. Creating the bin reads its last deletion timestamp from memcache.
  2. The read fails, and the driver logs the failure through logger.factory.
  3. Building logger.factory builds every registered logger. Core's syslog logger needs config.factory, which needs config.typed, which needs module_handler, which is still under construction.

It appears that any logger depending on the config factory triggers this. Sites that only use dblog are not affected, because that logger only needs the database. Note, the fallback in #3480438 does not help here either.

When a site is using APC, the failure is logged according to the failure_log_interval (every 60 seconds by default), so only one request per interval hits the fatal. Drush has no APCu on the command line by default, so every drush command fails while the server is unreachable.

Since kernel tests run on the container builder, it did not catch this because it tolerates circular references at runtime.

Issue fork memcache-3641652

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

japerry created an issue.

owilliwo’s picture

Confirming this on a production site (Drupal 11.4.13, memcache 8.x-2.9 then 8.x-2.10, Acquia, syslog enabled): three 500s over ten days, each during a memcached outage, one request per web node per failure_log_interval.

One more entry point than module_handler, in case it matters for the test coverage. Our production traces start from an HTTP middleware that needs the config factory early, so the bin being built is cache.config rather than cache.bootstrap:

http_kernel -> http_middleware.remove_http_headers -> remove_http_headers.config_manager -> config.factory -> config.storage -> cache.config -> logger.factory -> logger.syslog

(Drush on the same site hits the module_handler -> cache.bootstrap path
described in the summary.)

Tested MR !83 on 8.x-2.10 with the memcached extension, APCu and syslog, the
server pointed at a closed port:

  • before: first request after the interval returns the 500 above, and drush status fails;
  • after: no 500, drush status boots, and the failure is written to the Drupal log on the next failing read, as described.