UpdateBackend leads to broken config cache during updates

Created on 13 August 2025, 2 days ago

Problem/Motivation

We noticed that config updates in hook_update_N were not taking hold unless we deleted the config cache bin. That's because config storage is CachedStorage and every config change writes to storage and cache at the same time. But when using UpdateKernel the cache backends are UpdateBackend which avoids gets/sets and only allows deletes. Thereby effectively leaving the config cache in a broken state. I bet this happens in hook_post_update_NAME as well due to the UpdateKernel still being used.

  • Updates use \Drupal\Core\Update\UpdateKernel
  • This sets cache factory to UpdateCacheBackendFactory
  • That sets all cache backends to UpdateBackend
  • UpdateBackend only allows deletes from cache, get and set are null
  • So config never gets written to cache

cache.config bin is treated differently than any other bin.

Huge discussion thread https://drupal.slack.com/archives/C1BMUQ9U6/p1755012481343729

I also noticed UpdateBackend does not implement \Drupal\Core\Cache\CacheBackendInterface::invalidate or \Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple or \Drupal\Core\Cache\CacheBackendInterface::invalidateAll

Steps to reproduce

Modify config in an update hook, noticed cache_config is incorrect without a cache rebuild

Proposed resolution

  1. \Drupal\Core\Update\UpdateCacheBackendFactory::get should use the normal cache backend for config.
  2. UpdateBackend should delete cache on `set`, because `set` means something is invalid and should be deleted

The answer shouldn't be "just always delete caches" when there could be 1,000 entries and just one config was modified. If there are performance concerns on `set` doing deletes, we could batch them into a terminate. That could be a benefit for avoiding deleting caches until updates are finished.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

configuration system

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024