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
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
Comment #3
simonbaeseIf 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.
Comment #4
simonbaesePlease also let me know how to set up the test to observe the error in the CI pipelines.
Comment #5
simonbaeseOk, 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.
Comment #6
mondrakeCould this be just another manifestation of #3405976: Transaction autocommit during shutdown relies on unreliable object destruction order (xdebug 3.3+ enabled) & friends?
Comment #7
simonbaese@mondrake Thank you. That is a nice pointer. Indeed, turning off XDebug or using
xdebug.mode=debugprevents 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.Comment #8
mondrake@simonbaese we have some issues open like #3398767: Allow returning explicitly to the prior nesting level in transactions (aka allow explicit COMMIT in Transaction objects) and #3406985: Convert all transactions in core to use explicit ::commitOrRelease(), but we probably need a meta plan issue. I'll try to open one and reparent this issue to that.
Comment #9
mondrakeComment #10
mondrakeComment #11
quietone commentedThis would be fixed on 11.x first.