Updated: Comment #N

Problem/Motivation

Apparently since #2171683: Remove all Simpletest overrides and rely on native multi-site functionality instead and despite #2193521: Simpletest suffixes are not guaranteed to be unique, we're seeing a new type of random missing table fails.

It looks like this:

[12-Feb-2014 09:58:09 UTC] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupaltestbotmysql.simpletest915391semaphore' doesn't exist' in /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Database/Statement.php:61
Stack trace:
#0 /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Database/Statement.php(61): PDOStatement->execute(Array)	
#1 /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Database/Connection.php(537): Drupal\Core\Database\Statement->execute(Array, Array)
#2 /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php(34): Drupal\Core\Database\Connection->query('INSERT INTO {se...', Array, Array)
#3 /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php(71): Drupal\Core\Database\Driver\mysql\Insert->execute()	
#4 /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Utility/CacheArray.ph in /var/lib/drupaltestbot/sites/default/files/checkout/core/lib/Drupal/Core/Database/Connection.php on line 569

So this is triggered in CacheArray::__destruct(), on the lock() call.

Proposed resolution

Options:
a) Figure out where and what invokes it, reset it early enough in TestBase::restoreEnvironment(), just like drupal_static(), which this apparently isn't, or has additional references to it somewhere. Or maybe __destruct() is sometimes just not called immediately? Then we can't solve it like this.
b) Convert SchemaCache to CacheCollector and remove CacheArray. See #2185015: Remove SchemaCache and CacheArray
c) Add a hack for now that checks if the table exists

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

This is a very old issue we've regressed:

+    // Change the database prefix.
+    // All static variables need to be reset before the database prefix is
+    // changed, since Drupal\Core\Utility\CacheArray implementations attempt to
+    // write back to persistent caches when they are destructed.
+    $this->changeDatabasePrefix();
+    if (!$this->setupDatabasePrefix) {
+      return FALSE;
     }

From #1563620: All unit tests blow up with a fatal error.

Of the options, I'd probably bump #2185015: Remove SchemaCache and CacheArray to critical and mark this duplicate.

Berdir’s picture

Wondering if we should do c) then though, because this is happen pretty frequent right now.

catch’s picture

Yeah if the other issue is critical that seems fine as a stop-gap.

catch’s picture

Status: Active » Needs review

The last submitted patch, 4: cache-array-stop-gap-2194357-1.patch, failed testing.

The last submitted patch, 4: cache-array-stop-gap-2194357-1.patch, failed testing.

The last submitted patch, 4: cache-array-stop-gap-2194357-1.patch, failed testing.

alexpott’s picture

Patches attached run Drupal\file\Tests\UsageTest 100 times. One version adds a usleep to TestBase::restoreEnvironment()

The last submitted patch, 9: 2194357.9.test-only.patch, failed testing.

alexpott’s picture

alexpott’s picture

9: 2194357.9.test-only.patch queued for re-testing.

alexpott’s picture

alexpott’s picture

9: 2194357.9.test-only.patch queued for re-testing.

alexpott’s picture

alexpott’s picture

9: 2194357.9.test-only.patch queued for re-testing.

alexpott’s picture

First time we submitted #9 tests 5 out of 6 passed. One of the patches without usleep failed [MySQL] 3,400 pass(es), 63 fail(s), and 3 exception(s).

The last submitted patch, 9: 2194357.9.test-only.patch, failed testing.

The last submitted patch, 9: 2194357.9.test-only.patch, failed testing.

The last submitted patch, 9: 2194357.9.test-only-usleep.patch, failed testing.

alexpott’s picture

The last submitted patch, 21: 2194357.21.test-only.patch, failed testing.

alexpott’s picture

FileSize
742 bytes

The "real" patch.

The last submitted patch, 21: 2194357.21.test-only.patch, failed testing.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Let's go ahead :-) (No reason to wait 2 more hours, me thinks.)

star-szr’s picture

Title: CacheArray::__destruct() invoked after test tables have been remoeved » CacheArray::__destruct() invoked after test tables have been removed

Typo fix, don't mind me.

The last submitted patch, 21: 2194357.21.test-only.patch, failed testing.

The last submitted patch, 21: 2194357.21.test-only.patch, failed testing.

The last submitted patch, 21: 2194357.21.test-only.patch, failed testing.

Berdir’s picture

#21 looks beautiful ;)

Let's get this in ASAP.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed cec21a6 and pushed to 8.x. Thanks!

Committed as an emergency hotfix even though I worked on this patch due to excessively high amount of random fails.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.