Problem/Motivation
With every single Drupal 10 site that I manage, I get this error as soon as I update Drupal core. I suppose it's possible that this is somehow a result of some contrib module we are using in our sites, but the backtrace does not reveal anything outside of core, so it's really hard to tell for sure.
With the most recent one I tried doing all module updates first (including some major version updates) to try and ensure 10.3 compatibility as much as possible in advance. Some, however, cannot be updated to until after the core update.
Here is the full output of the error including the backtrace:
Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "cache.bootstrap", path: "module_handler -> cache.bootstrap -> cache.backend.database -> Drupal\Component\Datetime\TimeInterface -> state". in Drupal\Component\DependencyInjection\Container->get() (line 149 of core/lib/Drupal/Component/DependencyInjection/Container.php).
Drupal\Component\DependencyInjection\Container->get('cache.bootstrap', 1) (Line: 438)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
Drupal\Component\DependencyInjection\Container->createService(Array, 'state') (Line: 179)
Drupal\Component\DependencyInjection\Container->get('state', 1) (Line: 438)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
Drupal\Component\DependencyInjection\Container->createService(Array, 'Drupal\Component\Datetime\TimeInterface') (Line: 179)
Drupal\Component\DependencyInjection\Container->get('Drupal\Component\Datetime\TimeInterface', 1) (Line: 438)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.backend.database') (Line: 179)
Drupal\Component\DependencyInjection\Container->get('cache.backend.database') (Line: 104)
Drupal\Core\Cache\ChainedFastBackendFactory->get('bootstrap') (Line: 110)
Drupal\Core\Cache\CacheFactory->get('bootstrap')
call_user_func_array(Array, Array) (Line: 257)
Drupal\Component\DependencyInjection\Container->createService(Array, 'cache.bootstrap') (Line: 179)
Drupal\Component\DependencyInjection\Container->get('cache.bootstrap', 1) (Line: 438)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 239)
Drupal\Component\DependencyInjection\Container->createService(Array, 'module_handler') (Line: 179)
Drupal\Component\DependencyInjection\Container->get('module_handler') (Line: 615)
Drupal\Core\DrupalKernel->preHandle(Object) (Line: 46)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Similar issues have been reported on various modules due to the dependency on the datetime service for the new state cache. However, all of the services showing in this dependency chain are core services. Reviewing the core services yml file I can see how this circular reference occurs, with the full path looking like this:
module_handler -> cache.bootstrap -> cache.backend.database -> datetime.time -> state -> cache.bootstrap
Steps to reproduce
In my case, simply updating core to 10.3 causes this issue, on every single site I apply the update to. Then, try to load the site or run any drush commands (drush updb, drush cr, drush status etc) produce the error.
Proposed resolution
Update the dependency chain within these core services to get the database service without that coming back around to the cache.bootstrap service again during bootstrap phase.
How exactly to achieve that, I don't know.