Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291721

Faulty permanent config cache has been set to the cache backend on failed sql server connection

$
0
0

Problem/Motivation

in core/lib/Drupal/Core/Config/DatabaseStorage.php

public function readMultiple(array $names) {
    $list = [];
    try {
      $list = $this->connection->query('SELECT name, data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name IN ( :names[] )', [':collection' => $this->collection, ':names[]' => $names], $this->options)->fetchAllKeyed();
      foreach ($list as &$data) {
        $data = $this->decode($data);
      }
    }
    catch (\Exception $e) {
      // If we attempt a read without actually having the database or the table
      // available, just return an empty array so the caller can handle it.
    }
    return $list;
  }

if there is any connection failure, exception will be catched, and an empty value will be returned.
According to the comment, the caller should handle it

while in
core/lib/Drupal/Core/Config/CachedStorage.php -> readMultiple

      $list = $this->storage->readMultiple($names_to_get);
      // Cache configuration objects that were loaded from the storage, cache
      // missing configuration objects as an explicit FALSE.
      $items = [];
      foreach ($names_to_get as $name) {
        $data = isset($list[$name]) ? $list[$name] : FALSE;
        $data_to_return[$name] = $data;
        $items[$cache_keys_map[$name]] = ['data' => $data];
      }
      $this->cache->setMultiple($items);

looks like it just set the FALSE to the cache backend

Proposed resolution

I am not sure the exact fix yet, but in my opinion, we should not set a permanent faulty cache to the cache backend when there is an exception on getting the data


Viewing all articles
Browse latest Browse all 291721

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>