Problem/Motivation

The changes in the issue #3440848: Ensure post transaction callbacks are only at the end of the root Drupal transaction 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.

Issue fork drupal-3495554

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

simonbaese created an issue. See original summary.

simonbaese’s picture

If this is an error in the provided test, please change the issue type to "Support Request". In that case, we should add a change note to #3440848: Ensure post transaction callbacks are only at the end of the root Drupal transaction because it is unclear what needs to be adjusted.

simonbaese’s picture

Please also let me know how to set up the test to observe the error in the CI pipelines.

simonbaese’s picture

Status: Active » Postponed

Ok, apparently the kernel tests pass in the pipeline. Maybe this is a problem with DDEV? Could someone give a pointer to what the issue could be? I will investigate a little more and put this issue on postponed.

simonbaese’s picture

@mondrake Thank you. That is a nice pointer. Indeed, turning off XDebug or using xdebug.mode=debug prevents the error. Do you think there is value in keeping this issue open? Maybe we can cross-reference and close it if there are other open issues.

mondrake’s picture

mondrake’s picture

quietone’s picture

Version: 10.3.x-dev » 11.x-dev

This would be fixed on 11.x first.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.