When I change the default cache class in settings.php using the following:
$settings['cache']['default'] = 'cache.backend.memcache';
I'm getting the error:
Failed to log error: Symfony\\Component\\DependencyInjection\\Exception\\ServiceCircularReferenceException: Circular reference detected for service "cache.backend.memcache", path: "http_kernel -> http_middleware.negotiation -> http_middleware.reverse_proxy -> http_middleware.page_cache -> cache.render -> cache.backend.memcache -> memcache.factory -> logger.channel.memcache -> logger.factory -> logger.syslog -> config.factory -> config.storage -> cache.config". in Drupal\\Component\\DependencyInjection\\Container->get() (line 147 of /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php). #0 /path/to/drupal/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php(85): Drupal\\Component\\DependencyInjection\\Container->get('cache.backend.m...')\n#1 /path/to/drupal/core/lib/Drupal/Core/Cache/CacheFactory.php(83): Drupal\\Core\\Cache\\ChainedFastBackendFactory->get('config')\n#2 [internal function]: Drupal\\Core\\Cache\\CacheFactory->get('config')\n#3 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(254): call_user_func_array(Array, Array)\n#4 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'cache.config')\n#5 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('cache.config', 1)\n#6 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(236): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Object(stdClass))\n#7 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'config.storage')\n#8 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('config.storage', 1)\n#9 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(236): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Object(stdClass))\n#10 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'config.factory')\n#11 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('config.factory', 1)\n#12 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(236): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Object(stdClass))\n#13 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'logger.syslog')\n#14 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('logger.syslog', 1)\n#15 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(329): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Object(stdClass))\n#16 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'logger.factory')\n#17 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('logger.factory', 1)\n#18 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(248): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Array)\n#19 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'logger.channel....')\n#20 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('logger.channel....', 1)\n#21 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(236): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Object(stdClass))\n#22 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'memcache.factor...')\n#23 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('memcache.factor...', 1)\n#24 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(236): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Object(stdClass))\n#25 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'cache.backend.m...')\n#26 /path/to/drupal/core/lib/Drupal/Core/Cache/CacheFactory.php(83): Drupal\\Component\\DependencyInjection\\Container->get('cache.backend.m...')\n#27 [internal function]: Drupal\\Core\\Cache\\CacheFactory->get('render')\n#28 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(254): call_user_func_array(Array, Array)\n#29 /path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'cache.render')\n#30 /path/to/drupal/...
I have memcached installed and active on the server
I'm not adding any other configurations to settings.php file
any idea what is causing this error?
Comments
Comment #2
Aghiad commentedComment #3
Aghiad commentedComment #4
misc commentedInteresting - could you give some information about you setup, drupal version, php version etc. ?
Comment #5
Aghiad commentedDrupal version: 8.2.6
PHP version: 5.6.30
Memcache version: 3.0.8
Server: CentOS 7
I'm using PECL memcache
here is the content of /etc/httpd/conf.d/memcache.ini:
in /sites/default/settings.php I only added this line of code:
$settings['cache']['default'] = 'cache.backend.memcache';Comment #6
misc commentedCould you first try to update drupal core and see if you get the same problem?
Comment #7
damiankloip commentedI think I know why here. Since we started injecting the logger a few days ago, so we could remove the old error handling function - see http://cgit.drupalcode.org/memcache/commit/?id=ed98d69 . So I would be almost certain that if you disabled syslog, just to test this, it would work fine. The trouble your are having is because the syslog logger has the config factory injected, which in turn uses the config cache, which then tries to get memcache, but memcache wants the logger :) It's kind of crappy that syslog has configuration injected, instead of settings.
So maybe memcache just needs to not use any loggers, and just throw exceptions.
Comment #8
hswong3i commented@damiankloip agree that syslog shouldn't use config cache since it is a base services... Anyway looking for core changes really take time, and most use case as mine will always enable both syslog and memcache so get into trobule...
I give a try to revert ed98d69, but also keep the changes of remove memcache.module by replacing the memcache_log_warning() with closures inside register_shutdown_function() (see this example). For sure that the implementation could be more elegant ;-)
Patch via memcache-8.x-2.x-dev, tested with Drupal core 8.3.4 and PHP-FPM 7.1.6, no more circular reference detected.
Comment #9
Aghiad commentedThanks @hswong3i for the patch,
actually it worked!
and the error is gone
now I'm having another error. I think it's not related to this issue, but if you guys can help me I'll be thankful!
(I can open a new issue if you want)
here is the error:
Failed to log error: Drupal\\memcache\\MemcacheException: Memcache instance could not be initialized. Check memcache is running and reachable in Drupal\\memcache\\DrupalMemcacheFactory->get() (line 141 of/path/to/drupal/modules/memcache/src/DrupalMemcacheFactory.php). #0/path/to/drupal/modules/memcache/src/MemcacheBackendFactory.php(72): Drupal\\memcache\\DrupalMemcacheFactory->get('bootstrap')\n#1/path/to/drupal/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php(85): Drupal\\memcache\\MemcacheBackendFactory->get('bootstrap')\n#2/path/to/drupal/core/lib/Drupal/Core/Cache/CacheFactory.php(83): Drupal\\Core\\Cache\\ChainedFastBackendFactory->get('bootstrap')\n#3 [internal function]: Drupal\\Core\\Cache\\CacheFactory->get('bootstrap')\n#4/path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(254): call_user_func_array(Array, Array)\n#5/path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'cache.bootstrap')\n#6/path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(494): Drupal\\Component\\DependencyInjection\\Container->get('cache.bootstrap', 1)\n#7/path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(236): Drupal\\Component\\DependencyInjection\\Container->resolveServicesAndParameters(Object(stdClass))\n#8/path/to/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 'module_handler')\n#9/path/to/drupal/core/lib/Drupal/Core/DrupalKernel.php(544): Drupal\\Component\\DependencyInjection\\Container->get('module_handler')\n#10/path/to/drupal/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(45): Drupal\\Core\\DrupalKernel->preHandle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#11/path/to/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#12 ...as I mentioned erlier, I'm using PECL memcache.
Comment #10
delta commentedApplying the patch in #8 fix the issue.
Bump to major since the module doesn't work at all without this patch.
Thanks for the patch @hswong3i
Comment #11
misc commentedTested and works fine here also.
Comment #12
damiankloip commentedI think in this case we should not bother trying to log to be honest. If E.g. you couldn't connect to memcache and still using the syslog handler which was also using the config cache (memcache), your logger wouldn't work either way. This is why I think we should just remove the attempt to log in these cases and just throw exceptions.
Comment #13
damiankloip commentedComment #14
delta commentedLast patch work fine, I use it in production. +1 for throwing exception instead of using the logger which would be broken anyway in this case @damiankloip
Comment #15
damiankloip commentedok, let's just get this in then! I'll cut another tag and release too.
Comment #17
damiankloip commentedhttps://www.drupal.org/project/memcache/releases/8.x-2.0-alpha4
Comment #19
krystalcode commentedRaised issue in Drupal with potential solution: https://www.drupal.org/project/drupal/issues/3103620