Error unpiling database transactions with MySQL driver in kernel tests

Created on 22 December 2024, 2 days ago

Problem/Motivation

The changes in the issue 🐛 Ensure post transaction callbacks are only at the end of the root Drupal transaction Fixed cause a regression that leads to an error while unpiling database transactions in "some scenarios". One such scenario is kernel tests that install an entity schema and do assertions on requests. The change was introduced with Drupal 10.3.2.

PHP Fatal error:  Uncaught TypeError: Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must be of type object, null given, called in /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php on line 585 and defined in /var/www/html/web/core/lib/Drupal/Core/Database/StatementWrapperIterator.php:55
Stack trace:
#0 /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php(585): Drupal\Core\Database\StatementWrapperIterator->__construct()
#1 /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php(851): Drupal\Core\Database\Connection->prepareStatement()
#2 /var/www/html/web/core/lib/Drupal/Core/Database/Query/Select.php(524): Drupal\Core\Database\Connection->query()
#3 /var/www/html/web/core/lib/Drupal/Core/Database/Query/Merge.php(379): Drupal\Core\Database\Query\Select->execute()
#4 /var/www/html/web/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php(42): Drupal\Core\Database\Query\Merge->execute()
#5 /var/www/html/web/core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php(45): Drupal\Core\Cache\DatabaseCacheTagsChecksum->doInvalidateTags()
#6 [internal function]: Drupal\Core\Cache\DatabaseCacheTagsChecksum->rootTransactionEndCallback()
#7 /var/www/html/web/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php(488): call_user_func()
#8 /var/www/html/web/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php(296): Drupal\Core\Database\Transaction\TransactionManagerBase->processPostTransactionCallbacks()
#9 /var/www/html/web/core/lib/Drupal/Core/Database/Transaction.php(93): Drupal\Core\Database\Transaction\TransactionManagerBase->unpile()
#10 [internal function]: Drupal\Core\Database\Transaction->__destruct()
#11 {main} thrown in /var/www/html/web/core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 55

Steps to reproduce

Please consult the test provided in the merge request. The error is only observed when using a MySQL database driver. The test does not fail for other database drivers, such as SQLite.

The prepared test fails with MySQL5.7, MariaDB 10.3 and MariaDB 10.6.

🐛 Bug report
Status

Active

Version

10.3

Component

database system

Created by

🇩🇪Germany simonbaese Berlin

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