diff -u b/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php --- b/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -275,11 +275,16 @@ */ public function deleteMultiple(array $cids) { $cids = array_values(array_map(array($this, 'normalizeCid'), $cids)); - // Delete in chunks when a large array is passed. - foreach (array_chunk($cids, 1000) as $cids_chunk) { - $this->connection->delete($this->bin) - ->condition('cid', $cids_chunk, 'IN') - ->executeEnsuringTable($this); + try { + // Delete in chunks when a large array is passed. + foreach (array_chunk($cids, 1000) as $cids_chunk) { + $this->connection->delete($this->bin) + ->condition('cid', $cids_chunk, 'IN') + ->execute(); + } + } + catch (\Exception $e) { + $this->catchException($e); } } @@ -308,7 +313,12 @@ * Implements Drupal\Core\Cache\CacheBackendInterface::deleteAll(). */ public function deleteAll() { - $this->connection->truncate($this->bin)->executeEnsuringTable($this); + try { + $this->connection->truncate($this->bin)->execute(); + } + catch (\Exception $e) { + $this->catchException($e); + } } /** @@ -442,2 +452,20 @@ + /** + * Act on an exception when cache might be stale. + * + * If the {cachetags} table does not yet exist, that's fine but if the table + * exists and yet the query failed, then the cache is stale and the + * exception needs to propagate. + * + * @param $e + * The exception. + * @param string|null $table_name + * The table name, defaults to $this->bin. Can be cachetags. + */ + protected function catchException(\Exception $e, $table_name = NULL) { + if ($this->connection->schema()->tableExists($table_name ?: $this->bin)) { + throw $e; + } + } + /** diff -u b/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php --- b/core/lib/Drupal/Core/Database/Schema.php +++ b/core/lib/Drupal/Core/Database/Schema.php @@ -691,7 +691,8 @@ * An object providing the schema * * @return bool - * TRUE if the table exists, FALSE if it does not. + * TRUE if the table already existed or now exists, FALSE if there was an + * error and it does not. */ public function ensureTableExists($table_name, SchemaProviderInterface $schema_provider) { try { diff -u b/core/modules/system/src/Tests/Database/SelectTest.php b/core/modules/system/src/Tests/Database/SelectTest.php --- b/core/modules/system/src/Tests/Database/SelectTest.php +++ b/core/modules/system/src/Tests/Database/SelectTest.php @@ -43,7 +43,7 @@ // The table should be recreated, add back the sample data and re-run the // test. try { - self::addSampleData(); + static::addSampleData(); } catch (\Exception $e) { // Ignore adding rows to tables already filled.