Circular reference detected for service cache.bootstrap

Created on 24 July 2024, about 2 months ago
Updated 25 July 2024, about 1 month ago

Problem/Motivation

Getting this error post drupal core upgrade to 10.3.1

Circular reference detected for service "cache.bootstrap", path: "module_handler -> cache.bootstrap -> cache.backend.database -> Drupal\Component\Datetime\TimeInterface -> state -> cache.bootstrap".

PHP Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "cache.backend.database", path: "http_kernel -> http_middleware.ajax_page_state -> http_middleware.negotiation -> http_middleware.reverse_proxy -> http_middleware.page_cache -> cache.page -> cache.backend.database -> Drupal\Component\Datetime\TimeInterface -> state -> cache.bootstrap -> cache.backend.database". in /var/www/html/vendor/symfony/dependency-injection/Container.php:222
Stack trace:
#0 /var/www/html/vendor/symfony/dependency-injection/Container.php(211): Symfony\Component\DependencyInjection\Container::make(Object(Drupal\Core\DependencyInjection\ContainerBuilder), 'cache.backend.d...', 2)
#1 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(547): Symfony\Component\DependencyInjection\Container->get('cache.backend.d...', 2)
#2 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(531): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('cache.backend.d...', 1)
#3 /var/www/html/web/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php(98): Symfony\Component\DependencyInjection\ContainerBuilder->get('cache.backend.d...')
#4 /var/www/html/web/core/lib/Drupal/Core/Cache/CacheFactory.php(110): Drupal\Core\Cache\ChainedFastBackendFactory->get('bootstrap')
#5 /var/www/html/web/core/lib/Drupal/Core/Update/UpdateCacheBackendFactory.php(46): Drupal\Core\Cache\CacheFactory->get('bootstrap')
#6 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1121): Drupal\Core\Update\UpdateCacheBackendFactory->get('bootstrap')
#7 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(586): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'cache.bootstrap')
#8 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1258): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('cache.bootstrap', 1, Array, true)
#9 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1210): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Reference), Array, true)
#10 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1110): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)
#11 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(586): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'state')
#12 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1258): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('state', 1, Array, true)
#13 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1210): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Reference), Array, true)
#14 /var/www/html/vendor/symfony/dependency-injection/ContainerBuilder.php(1110): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Array, Array, true)

Steps to reproduce

Drupal core upgrade to 10.3.1

🐛 Bug report
Status

Closed: works as designed

Version

10.3

Component
Bootstrap 

Last updated 2 days ago

No maintainer
Created by

🇮🇳India sanket1007

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

Comments & Activities

  • Issue created by @sanket1007
  • 🇮🇳India sanket1007

    I already checked this issue https://www.drupal.org/project/lightning_workflow/issues/3457016 🐛 Circular reference detected for service "cache.backend.database". Active but in our case, we are not using this module and hence this issue looks like a regression due to some other module.

  • 🇺🇸United States cilefen

    This looks like https://drupal.stackexchange.com/questions/320037/servicecircularreferen...

    Can we have the list of modules installed and patches applied? Perhaps the complete composer.json would help.

  • 🇮🇳India sanket1007

    Sure, here is the composer.json file -

    {
        "name": "drupal/recommended-project",
        "description": "Project template for Drupal 8 projects with a relocated document root",
        "type": "project",
        "license": "GPL-2.0-or-later",
        "homepage": "https://www.drupal.org/project/drupal",
        "support": {
            "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
            "chat": "https://www.drupal.org/node/314178"
        },
        "repositories": [
            {
                "type": "path",
                "url": "src/packages/*"
            },
            {
                "type": "composer",
                "url": "https://packages.drupal.org/8"
            },
            {
                "type": "composer",
                "url": "https://asset-packagist.org"
            },
            {
                "type": "package",
                "package": {
                    "name": "toc/toc",
                    "version": "v0.3.2",
                    "type": "drupal-library",
                    "dist": {
                        "url": "https://raw.githubusercontent.com/jgallen23/toc/greenkeeper/update-all/dist/toc.min.js",
                        "type": "file"
                    }
                }
            }
        ],
        "require": {
            "bower-asset/countable": "^3.0",
            "bower-asset/dropzone": "^5.7",
            "bower-asset/history.js": "^1.8",
            "bower-asset/lunr": "^2.3",
            "bower-asset/prism": "^1.22",
            "bower-asset/slick-carousel": "^1.8",
            "commerceguys/addressing": "^2",
            "composer/installers": "^1.9",
            "cweagans/composer-patches": "^1.7",
            "drupal-ckeditor-libraries-group/fakeobjects": "^4.17",
            "drupal/access_unpublished": "^1.4",
            "drupal/address": "^2",
            "drupal/admin_toolbar": "^3.4",
            "drupal/auto_entitylabel": "^3.0@beta",
            "drupal/better_exposed_filters": "^6.0.3",
            "drupal/block_field": "^1.0@RC",
            "drupal/components": "^3",
            "drupal/config_filter": "^2.4",
            "drupal/config_ignore": "^2.4",
            "drupal/config_override_warn": "^1.3",
            "drupal/config_split": "^2.0@RC",
            "drupal/config_split_ignore": "dev-main",
            "drupal/content_lock": "^2.3.0",
            "drupal/core-composer-scaffold": "10.3.1",
            "drupal/core-project-message": "10.3.1",
            "drupal/core-recommended": "10.3.1",
            "drupal/crop": "^2.3",
            "drupal/ctools": "^4",
            "drupal/custom_book_block": "^1.0",
            "drupal/devel": "^5.1",
            "drupal/diff": "^1.0",
            "drupal/editor_md": "^4.0",
            "drupal/embed": "^1.5",
            "drupal/entity_browser": "^2.10",
            "drupal/entity_embed": "^1.4",
            "drupal/entity_reference_validators": "^1.0@beta",
            "drupal/entity_usage": "^2.0@beta",
            "drupal/environment_indicator": "^4.0",
            "drupal/externalauth": "^2.0",
            "drupal/fakeobjects": "^1.1",
            "drupal/fastly": "^4",
            "drupal/field_group": "^3.4.0",
            "drupal/file_delete_ui": "^1.0@beta",
            "drupal/fixed_block_content": "^1.2",
            "drupal/focal_point": "^2.0",
            "drupal/gin": "^3.0@RC",
            "drupal/gin_toolbar": "^1.0@RC",
            "drupal/hal": "^2.0",
            "drupal/inline_entity_form": "^1.0@RC",
            "drupal/jquery_ui": "^1.6.0",
            "drupal/jquery_ui_datepicker": "^2",
            "drupal/jquery_ui_slider": "^2",
            "drupal/jquery_ui_touch_punch": "^1.0",
            "drupal/jsonapi_extras": "^3.24",
            "drupal/layout_paragraphs": "^2.0",
            "drupal/lottiefiles_field": "^2.0",
            "drupal/markdown": "^3.0",
            "drupal/maxlength": "^2.1",
            "drupal/media_entity_browser": "^2.0@alpha",
            "drupal/media_entity_twitter": "^2.7",
            "drupal/metatag": "^1",
            "drupal/migrate_plus": "^6.0.0",
            "drupal/migrate_source_csv": "^3.5",
            "drupal/migrate_tools": "^6.0",
            "drupal/moderation_state_transitions_widget": "dev-main",
            "drupal/node_edit_protection": "^1.0",
            "drupal/node_revision_delete": "^1.0.0-rc6",
            "drupal/pantheon_advanced_page_cache": "^2.1",
            "drupal/paragraphs": "^1.16",
            "drupal/paragraphs_features": "^2",
            "drupal/pate": "^1.2.0",
            "drupal/pathauto": "^1.9",
            "drupal/preserve_changed": "^2.0@alpha",
            "drupal/purge": "^3.0",
            "drupal/redirect": "^1.9",
            "drupal/redis": "^1.7",
            "drupal/replicate": "^1.2",
            "drupal/replicate_actions": "^1.4",
            "drupal/replicate_ui": "^1.1",
            "drupal/scheduler": "^2.0",
            "drupal/scheduler_content_moderation_integration": "^2.0@beta",
            "drupal/schema_metatag": "^2.3",
            "drupal/sdc": "^2.0",
            "drupal/search_api": "^1.29",
            "drupal/select2": "^1.15",
            "drupal/simple_sitemap": "^4.1",
            "drupal/simplesamlphp_auth": "^4",
            "drupal/stage_file_proxy": "^2.1",
            "drupal/svg_formatter": "^2.0.2",
            "drupal/svg_image": "^3.0",
            "drupal/tmgmt": "^1.15",
            "drupal/tmgmt_smartling": "^9.6",
            "drupal/toc_js": "^2.1",
            "drupal/token": "^1.12",
            "drupal/token_custom": "^1.0@alpha",
            "drupal/token_filter": "^2.0",
            "drupal/tranc": "^1.0",
            "drupal/twig_field_value": "^2.0",
            "drupal/twig_tweak": "^3.1.3",
            "drupal/type_tray": "^1.2",
            "drupal/upgrade_status": "^4.0",
            "drupal/views_ajax_history": "^1.5",
            "drupal/views_bulk_operations": "^4.2",
            "drupal/webp": "^1.0@RC",
            "drupal/xmlsitemap": "^1.5",
            "drupal/yoast_seo": "^2.0",
            "drush/drush": "^12",
            "eluceo/ical": "^0.17",
            "league/commonmark": "^1.0",
            "league/csv": "^9.6",
            "npm-asset/jquery-ui-touch-punch": "^0.2.3",
            "npm-asset/select2": "^4.0",
            "oomphinc/composer-installers-extender": "^2.0",
            "phpspec/prophecy-phpunit": "^2.0",
            "psr/log": "^3.0",
            "simplesamlphp/assert": "^1.0",
            "simplesamlphp/composer-module-installer": "^1.3",
            "simplesamlphp/simplesamlphp": "^2.1",
            "symfony/browser-kit": "^6.3",
            "symfony/console": "^6",
            "symfony/css-selector": "^5",
            "symfony/debug": "^4",
            "symfony/dom-crawler": "^6",
            "symfony/framework-bundle": "^6",
            "toc/toc": "^0.3.2",
            "twig/twig": "^3",
            "vlucas/phpdotenv": "^4.1"
        },
        "require-dev": {
            "behat/mink-browserkit-driver": "^2.1",
            "behat/mink-selenium2-driver": "^1.4",
            "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
            "dmore/chrome-mink-driver": "^2.7",
            "drupal/coder": "8.3.13",
            "drupal/potx": "^1.0",
            "php-parallel-lint/php-parallel-lint": "^1.2",
            "phpro/grumphp": "^1.5.1",
            "squizlabs/php_codesniffer": "^3.5",
            "symfony/phpunit-bridge": "^5.2",
            "weitzman/drupal-test-traits": "^2.2"
        },
        "conflict": {
            "drupal/drupal": "*"
        },
        "minimum-stability": "dev",
        "prefer-stable": true,
        "config": {
            "sort-packages": true,
            "allow-plugins": {
                "dealerdirect/phpcodesniffer-composer-installer": true,
                "composer/installers": true,
                "cweagans/composer-patches": true,
                "drupal/core-composer-scaffold": true,
                "oomphinc/composer-installers-extender": true,
                "phpro/grumphp": true,
                "simplesamlphp/composer-module-installer": true,
                "drupal/core-project-message": true
            }
        },
        "autoload": {
            "psr-4": {
                "NewRelic\\": [
                    "src/"
                ]
            }
        },
        "autoload-dev": {
            "files": [
                "load.environment.php"
            ]
        },
        "extra": {
            "drupal-scaffold": {
                "locations": {
                    "web-root": "web/"
                },
                "file-mapping": {
                    "[web-root]/sites/development.services.yml": false
                }
            },
            "installer-types": [
                "bower-asset",
                "npm-asset",
                "component"
            ],
            "installer-paths": {
                "web/core": [
                    "type:drupal-core"
                ],
                "web/libraries/{$name}": [
                    "type:drupal-library",
                    "type:bower-asset",
                    "type:npm-asset"
                ],
                "web/modules/contrib/{$name}": [
                    "type:drupal-module"
                ],
                "web/profiles/contrib/{$name}": [
                    "type:drupal-profile"
                ],
                "web/themes/contrib/{$name}": [
                    "type:drupal-theme"
                ],
                "drush/Commands/{$name}": [
                    "type:drupal-drush"
                ],
                "web/modules/custom/{$name}": [
                    "type:drupal-custom-module"
                ],
                "web/themes/custom/{$name}": [
                    "type:drupal-custom-theme"
                ]
            },
            "composer-exit-on-patch-failure": true,
            "patchLevel": {
                "drupal/core": "-p2"
            },
            "patches": {
                "drupal/core": {
                    "Avoid PHP error when saving translatable media items": "https://www.drupal.org/files/issues/2019-02-11/ignore_width_height_on_untranslatable_field_comparision_2941092_8.patch",
                    "Issue #2761273: Make exposed filter values available as tokens for text areas": "https://www.drupal.org/files/issues/2022-10-30/2761273-50.patch",
                    "Issue #2985168: Allow Media Library to update media items in-place": "https://www.drupal.org/files/issues/2023-12-18/2985168-172.patch",
                    "Issue #3175146: Media Library required field error message is too vague": "https://www.drupal.org/files/issues/2023-05-22/3175146-19.patch",
                    "Issue #2539900: Markup wrongly escaped in delete link": "https://www.drupal.org/files/issues/2020-04-21/content_translation-2539900-fix_markup_escaped.patch",
                    "Issue #2873353: Allow updating lists to use allowed values function": "https://www.drupal.org/files/issues/2021-05-18/allow-allowed-values-function-update-D9-2873353_1.patch",
                    "NR patch: Add condition entity->book (see #97 from https://www.drupal.org/project/drupal/issues/2918537#comment-14824128)": "patches/book_20230822.patch",
                    "NR patch: Fix add child page link for Authoring Documentation": "patches/wta-2526-fix-add-child-page-link-for-authoring-documentation.patch",
                    "Issue #3323574: Page index isn't reset when use AJAX for Views module": "https://www.drupal.org/files/issues/2023-09-27/ajax-views-page-not-reset-issue-3323574-10.1.x-11.patch"
                },
                "drupal/access_unpublished": {
                    "Issue #2912066: Only show access unpublished element on relevant forms": "https://www.drupal.org/files/issues/2021-06-28/access_unpublished-only_node_edit-2912066-13.patch"
                },
                "drupal/auto_entitylabel": {
                    "Make Custom Token and Auto Entity Labels play nicely together": "patches/auto_entitylabel_token_fix.patch"
                },
                "drupal/ckeditor": {
                    "Issue #3065095: CKEditor native dialogs not clickable inside of jQuery UI dialogs": "https://www.drupal.org/files/issues/2022-11-22/3065095-71-1.0.x.patch"
                },
                "drupal/markdown": {
                    "Issue #3409277: Formstate incorrect interface error": "https://www.drupal.org/files/issues/2024-01-04/subformstate-incorrect-interface-error-3409277-4.patch"
                },
                "drupal/diff": {
                    "Issue #3227907: Fix current revision listed only for one translation": "https://www.drupal.org/files/issues/2021-08-12/3227907-4-list-current-revision-all-translations.diff"
                },
                "drupal/layout_paragraphs": {
                    "WTA-2403 - Set layout paragraphs widget to be multilingual": "patches/wta-2403-layout-paragraphs-set-widget-multilingual.patch",
                    "WTA-2620: Use modal width setting for component picker": "https://www.drupal.org/files/issues/2023-02-13/layout_paragraphs-3341449-3.patch"
                },
                "drupal/media_entity_twitter": {
                    "Issue #3207992: Media Library form doesn't respect source field constraint validators": "https://www.drupal.org/files/issues/2021-04-09/3207992-2.patch"
                },
                "drupal/migrate_tools": {
                    "Issue #3378047: Fix 'sync' performance": "https://www.drupal.org/files/issues/2024-03-11/3378047-21.patch"
                },
                "drupal/node_edit_protection": {
                    "Issue #2188085: No longer working after validation fails": "https://www.drupal.org/files/issues/2021-12-08/node-edit-protection-2188085-13-d8.patch"
                },
                "drupal/paragraphs": {
                    "Issue #3027525 Improve paragraphs validation errors": "https://www.drupal.org/files/issues/2022-02-07/3027525-14.patch",
                    "Alter widgets item mode using custom business logic.": "patches/paragraphs-alter-item-mode-when-building-widget.patch",
                    "Issue #3310161 Null coalesce view_mode": "https://www.drupal.org/files/issues/2022-09-22/3310161-11.patch"
                },
                "drupal/pate": {
                    "WTA-2166 contributor role": "patches/wta-2166-contributor-role--drupal-pate.patch"
                },
                "drupal/replicate_ui": {
                    "Issue #3215573: Allow editors to choose whether to replicate all translations or not": "https://www.drupal.org/files/issues/2021-05-27/3215573-6.patch"
                },
                "drupal/select2": {
                    "Issue #3211796: Issue with z-index when opening in modal dialog": "https://www.drupal.org/files/issues/2021-05-03/properfix_zindex_ckeditor-3211796-5.patch"
                },
                "drupal/simplesamlphp_auth": {
                    "Issue #3112851: Fix access denied after logging in user from OKTA": "https://www.drupal.org/files/issues/2020-06-22/3112851-4_0.patch",
                    "WTA-2661: Redirect to Authoring Documentation after logging in user from OKTA": "patches/wta-2661-redirect-to-authoring-documentation.patch"
                },
                "drupal/svg_formatter": {
                    "Issue #3284297: Extract dimensions from SVG image": "patches/svg_formatter-3284297.patch"
                },
                "drupal/tmgmt": {
                    "Issue #3188508: UX improvements on Locales source plugin form": "https://www.drupal.org/files/issues/2020-12-15/3188508-2.patch"
                },
                "drupal/tmgmt_smartling": {
                    "Issue #3172935: Do not perform API calls during config sync": "https://www.drupal.org/files/issues/2020-09-24/3172935-3.patch",
                    "Do not show cron warning on non-live environments": "patches/smartling-cron-messages.patch"
                },
                "drupal/toc_js": {
                    "Issue #3031413: Programmatically-created nodes have TOC always enabled by default": "https://www.drupal.org/files/issues/2019-02-07/3031413-2.patch",
                    "Force a couple config strings to be translated as interface strings": "patches/toc-js-translate-interface-strings.patch"
                },
                "drupal/token_custom": {
                    "Issue #2906903: Paragraph Tags Added to Tokens": "patches/2906903-enable-full-html.patch"
                },
                "drupal/yoast_seo": {
                    "Apply some project-specific customizations - 1": "patches/yoast-seo-project-specific-tweaks.patch",
                    "Issue #3394487: Uncaught DOMException": "https://www.drupal.org/files/issues/2023-11-03/3394487-failed-to-execute-remove-on-domtokenlist.patch"
                },
                "toc/toc": {
                    "WTA-2207: remove dash on empty prefix": "patches/wta-2207p2.patch"
                }
            },
            "composer-version": "^1.7.2"
        },
        "scripts": {
            "post-install-cmd": [
                "rm -rf vendor/simplesamlphp/simplesamlphp/config && ln -sf ../../../config/simplesamlphp/config vendor/simplesamlphp/simplesamlphp/config",
                "rm -rf vendor/simplesamlphp/simplesamlphp/metadata && ln -sf ../../../config/simplesamlphp/metadata vendor/simplesamlphp/simplesamlphp/metadata",
                "ln -sfn ../vendor/simplesamlphp/simplesamlphp/public web/simplesaml"
            ]
        }
    }
  • 🇺🇸United States cilefen

    What does the service definition for cache.backend.database in core/core.services.yml look like in that codebase?

    Are there any non-default cache bins or cache configurations on the site?

  • 🇮🇳India sanket1007

    cache.backend.database:
    class: Drupal\Core\Cache\DatabaseBackendFactory
    arguments: ['@database', '@cache_tags.invalidator.checksum', '@settings']
    tags:
    - { name: backend_overridable }

    Yes, we have cache bins on the site.

  • Status changed to Postponed: needs info about 1 month ago
  • 🇺🇸United States cilefen

    Ok, what are the complete cache configurations? Are settings or modules overriding core services?

  • 🇮🇳India sanket1007

    This is the cache bin that we have created in one of our module -

    nr_core.nr_cache:
    class: Drupal\Core\Cache\CacheBackendInterface
    factory: ['@cache_factory', 'get']
    arguments: ['nr_cache']
    tags:
    - { name: cache.bin }

  • 🇮🇳India sanket1007

    Also, I am using pantehon setup.

  • Status changed to Active about 1 month ago
  • Status changed to Postponed: needs info about 1 month ago
  • 🇺🇸United States cilefen

    The reason this happens in 10.3 is probably https://www.drupal.org/node/3177901 . I think you have something overriding cache.backend.database so that it depends on Drupal\Component\Datetime\TimeInterface and state.

    So there is also custom code? What exactly do you mean by Pantheon setup?

    I wish the circular dependency exception were more verbose. Some techniques you could try:

    • Disable modules that modify default caching.
    • Disable default cache overrides in settings.php or services.yml.

    I am postponing this issue until all information required to reproduce the bug is available.

  • 🇮🇳India sanket1007

    I found the issue, we were using time in our code which was causing the bug.

      nr_core.datetime.time:
        public: false
        class: 'Drupal\nr_core\Time'
        decorates: datetime.time
        arguments:
          - '@request_stack'
          - '@state'
        # Workaround for serializing decorated services. Remove when either
        # https://www.drupal.org/project/drupal/issues/2896993 or
        # https://www.drupal.org/project/drupal/issues/2531564 are fixed.
        properties:
          _serviceId: datetime.time

    Tried removing this dependency of - '@state' from here and it worked fine. Thanks

  • Status changed to Fixed about 1 month ago
  • Status changed to Closed: works as designed about 1 month ago
  • 🇺🇸United States JudyAkers

    I found that if I Remove this patch from Composer.json

    "drupal/calendar": {
    "#3396700: Creation of dynamic properties is deprecated": " https://www.drupal.org/files/issues/2023-10-26/calendar-dynamic-properti... "
    }

    The error goes away.

Production build 0.71.5 2024