Page MenuHomePhabricator

Running Cirrus extension unit tests on vagrant produces exception on shutdown
Closed, ResolvedPublic

Description

When running unit tests on vagrant, the following exception is produced at the end of the test:

PHP Fatal error: Uncaught exception 'DBUnexpectedError' with message 'Foreign domain connections are still in use (commonswiki).'

The backtrace is in https://phabricator.wikimedia.org/P4125

The connection to commons seems to be opened by GlobalUsage extension.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 313121 had a related patch set uploaded (by Aaron Schulz):
Use getConnectionRef() to handle missing reuseConnection() calls

https://gerrit.wikimedia.org/r/313121

Change 313121 merged by jenkins-bot:
Use getConnectionRef() to handle missing reuseConnection() calls

https://gerrit.wikimedia.org/r/313121

Maybe you rig openForeignConnection() to log a backtrace of callers, e.g.:

MWExceptionHandler::logException( new RuntimeException( 'foreign connection caller' ) );

Still happens after merging https://gerrit.wikimedia.org/r/313121.

I'll add backtrace for openForeignConnection() in a moment.

Backtrace:

#0  LoadBalancer->openForeignConnection() called at [/vagrant/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php:666]
#1  LoadBalancer->openConnection() called at [/vagrant/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php:575]
#2  LoadBalancer->getConnection() called at [/vagrant/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php:643]
#3  LoadBalancer->getConnectionRef() called at [/vagrant/mediawiki/extensions/GlobalUsage/GlobalUsage_body.php:300]
#4  GlobalUsage::getGlobalDB() called at [/vagrant/mediawiki/extensions/GlobalUsage/GlobalUsageHooks.php:188]
#5  GlobalUsageHooks::getGlobalUsage() called at [/vagrant/mediawiki/extensions/GlobalUsage/GlobalUsageHooks.php:37]
#6  GlobalUsageHooks::onLinksUpdateComplete()
#7  call_user_func_array() called at [/vagrant/mediawiki/includes/Hooks.php:195]
#8  Hooks::run() called at [/vagrant/mediawiki/includes/deferred/LinksUpdate.php:179]
#9  LinksUpdate->{closure}()
#10 call_user_func_array() called at [/vagrant/mediawiki/includes/libs/rdbms/database/Database.php:2531]
#11 Database->runOnTransactionIdleCallbacks() called at [/vagrant/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php:1153]
#12 LoadBalancer->{closure}()
#13 call_user_func_array() called at [/vagrant/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php:1380]
#14 LoadBalancer->forEachOpenMasterConnection() called at [/vagrant/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php:1162]
#15 LoadBalancer->runMasterPostTrxCallbacks() called at [/vagrant/mediawiki/includes/libs/rdbms/lbfactory/LBFactory.php:194]
#16 LBFactory->{closure}()
#17 call_user_func_array() called at [/vagrant/mediawiki/includes/libs/rdbms/lbfactory/LBFactorySimple.php:145]
#18 LBFactorySimple->forEachLB() called at [/vagrant/mediawiki/includes/libs/rdbms/lbfactory/LBFactory.php:196]
#19 LBFactory->commitMasterChanges() called at [/vagrant/mediawiki/includes/deferred/DeferredUpdates.php:248]
#20 DeferredUpdates::runUpdate() called at [/vagrant/mediawiki/includes/deferred/DeferredUpdates.php:221]
#21 DeferredUpdates::execute() called at [/vagrant/mediawiki/includes/deferred/DeferredUpdates.php:121]
#22 DeferredUpdates::doUpdates() called at [/vagrant/mediawiki/includes/deferred/DeferredUpdates.php:278]
#23 DeferredUpdates::tryOpportunisticExecute() called at [/vagrant/mediawiki/includes/deferred/DeferredUpdates.php:91]
#24 DeferredUpdates::addUpdate() called at [/vagrant/mediawiki/includes/page/WikiPage.php:2036]
#25 WikiPage->doCreate() called at [/vagrant/mediawiki/includes/page/WikiPage.php:1732]
#26 WikiPage->doEditContent() called at [/vagrant/mediawiki/tests/phpunit/MediaWikiTestCase.php:1028]
#27 MediaWikiTestCase->addCoreDBData() called at [/vagrant/mediawiki/tests/phpunit/MediaWikiTestCase.php:370]
#28 MediaWikiTestCase->run() called at [/vagrant/mediawiki/extensions/WikidataBuildResources/vendor/wikimedia/purtle/vendor/phpunit/phpunit/src/Framework/TestSuite.php:747]
#29 PHPUnit_Framework_TestSuite->run() called at [/vagrant/mediawiki/extensions/WikidataBuildResources/vendor/wikimedia/purtle/vendor/phpunit/phpunit/src/Framework/TestSuite.php:747]
#30 PHPUnit_Framework_TestSuite->run() called at [/vagrant/mediawiki/extensions/WikidataBuildResources/vendor/wikimedia/purtle/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:440]
#31 PHPUnit_TextUI_TestRunner->doRun() called at [/vagrant/mediawiki/extensions/WikidataBuildResources/vendor/wikimedia/purtle/vendor/phpunit/phpunit/src/TextUI/Command.php:149]
#32 PHPUnit_TextUI_Command->run() called at [/vagrant/mediawiki/extensions/WikidataBuildResources/vendor/wikimedia/purtle/vendor/phpunit/phpunit/src/TextUI/Command.php:100]
#33 PHPUnit_TextUI_Command::main() called at [/vagrant/mediawiki/tests/phpunit/phpunit.php:133]
#34 PHPUnitMaintClass->execute() called at [/vagrant/mediawiki/maintenance/doMaintenance.php:110]
#35 require(/vagrant/mediawiki/maintenance/doMaintenance.php) called at [/vagrant/mediawiki/tests/phpunit/phpunit.php:163]

Probably the $gu static singleton being kept alive so late due to being static.

With connection ref usage, I don't see the point in the singleton...I'll just remove it.

Change 313183 had a related patch set uploaded (by Aaron Schulz):
Remove pointless getGlobalUsage() singleton

https://gerrit.wikimedia.org/r/313183

Change 313183 merged by jenkins-bot:
Remove pointless getGlobalUsage() singleton

https://gerrit.wikimedia.org/r/313183

aaron claimed this task.