- π©πͺGermany mkalkbrenner π©πͺ
We ran into this issue multiple times over the last two weeks, like @longwave in a running Drupal 9.5 during normal operations.
One or more calls of drush cr solved the issue for some days.
But it only happend on the production systems, never on a local development environment.I had a look at the code and see some problematic stuff.
The key value store is database table. We use MariaDB replication. And we noticed a replication drift over the last weeks. Could it be that some action triggers the rebuild of the data but another process still reads the outdated data from a replicant which is some seconds behind the master. So this outdated data gets populated to the caches?
In that case, key value store database queries should be changed to always query the database master.But the same could also happen if you use Redis or Memcache for fast chained caches.
The new data could be written to the key value cache within a database transaction that also invalidates the cache. But for these non-Database caches, we don't have any transaction context. So another request could still read the old data from the key value store until the transaction gets committed and write old data into the cache.