MediaWiki 1.30.0-alpha (3d26a96) PHP 7.1.1 (apache2handler) MariaDB 10.1.21-MariaDB ICU 57.1
[Bug56269] Exception thrown with an uncommited database transaction: [d8d3f093942c3e9b92a83e61] /mw-master/index.php/Special:Browse/:Recurring-5Fevents-2F41 Wikimedia\Rdbms\DBTransactionError from line 200 of ...\includes\libs\rdbms\lbfactory\LBFactory.php: MWCallableUpdate::doUpdate: transaction round 'SMW\MediaWiki\Jobs\UpdateJob::run' already started. #0 ...\includes\deferred\DeferredUpdates.php(265): Wikimedia\Rdbms\LBFactory->beginMasterChanges(string) #1 ...\includes\deferred\DeferredUpdates.php(228): DeferredUpdates::runUpdate(MWCallableUpdate, Wikimedia\Rdbms\LBFactorySimple, integer) #2 ...\includes\deferred\DeferredUpdates.php(136): DeferredUpdates::execute(array, string, integer) #3 ...\includes\deferred\DeferredUpdates.php(95): DeferredUpdates::doUpdates(string) #4 ...\includes\deferred\DeferredUpdates.php(119): DeferredUpdates::addUpdate(MWCallableUpdate, integer) #5 ...\includes\libs\objectcache\BagOStuff.php(216): DeferredUpdates::addCallableUpdate(Closure) #6 ...\includes\libs\objectcache\BagOStuff.php(183): BagOStuff->trackDuplicateKeys(string) #7 ...\includes\parser\Preprocessor.php(110): BagOStuff->get(string) #8 ...\includes\parser\Preprocessor_DOM.php(152): Preprocessor->cacheGetTree(string, integer) #9 ...\includes\parser\Parser.php(2889): Preprocessor_DOM->preprocessToObj(string, integer) #10 ...\includes\parser\Parser.php(4121): Parser->preprocessToDom(string) #11 ...\includes\parser\Parser.php(1339): Parser->formatHeadings(string, string, boolean) #12 ...\includes\parser\Parser.php(451): Parser->internalParse(string) #13 ...\includes\content\WikitextContent.php(330): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer) #14 ...\includes\content\AbstractContent.php(497): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput) #15 ...\extensions\SemanticMediaWiki\includes\ContentParser.php(203): AbstractContent->getParserOutput(Title, integer, ParserOptions, boolean) #16 ...\extensions\SemanticMediaWiki\includes\ContentParser.php(156): SMW\ContentParser->fetchFromContent() #17 ...\extensions\SemanticMediaWiki\src\MediaWiki\Jobs\UpdateJob.php(139): SMW\ContentParser->parse() #18 ...\extensions\SemanticMediaWiki\src\MediaWiki\Jobs\UpdateJob.php(112): SMW\MediaWiki\Jobs\UpdateJob->needToParsePageContentBeforeUpdate() #19 ...\extensions\SemanticMediaWiki\src\MediaWiki\Jobs\UpdateJob.php(80): SMW\MediaWiki\Jobs\UpdateJob->doPrepareForUpdate() #20 ...\extensions\SemanticMediaWiki\src\MediaWiki\Jobs\UpdateJob.php(61): SMW\MediaWiki\Jobs\UpdateJob->doUpdate() #21 ...\includes\jobqueue\JobRunner.php(289): SMW\MediaWiki\Jobs\UpdateJob->run() #22 ...\includes\jobqueue\JobRunner.php(189): JobRunner->executeJob(SMW\MediaWiki\Jobs\UpdateJob, Wikimedia\Rdbms\LBFactorySimple, BufferingStatsdDataFactory, integer) #23 ...\includes\MediaWiki.php(973): JobRunner->run(array) #24 ...\includes\MediaWiki.php(959): MediaWiki->triggerSyncJobs(integer, MediaWiki\Logger\LegacyLogger) #25 ...\includes\MediaWiki.php(911): MediaWiki->triggerJobs() #26 ...\includes\MediaWiki.php(731): MediaWiki->restInPeace(string) #27 ...\includes\MediaWiki.php(750): MediaWiki->{closure}() #28 ...\includes\MediaWiki.php(554): MediaWiki->doPostOutputShutdown(string) #29 ...\index.php(43): MediaWiki->run()
Issue
The issue appears with BagOStuff::trackDuplicateKeys invoking DeferredUpdates::addCallableUpdate while a job is active and causes a "MWCallableUpdate::doUpdate: transaction round 'SMW\MediaWiki\Jobs\UpdateJob::run' already started."
... and before someone (as it has been so in the past) to declare this to be a SMW issue and closes the task before investigating, here is an example that doesn't involve SMW at all.
[Bug56269] Exception thrown with an uncommited database transaction: [dcf60ceb63f75441b711c08b] /mw-master/index.php?search=Lorem%20ipsum-1d&title=Special%3ASearch Wikimedia\Rdbms\DBTransactionError from line 200 of ...\includes\libs\rdbms\lbfactory\LBFactory.php: MWCallableUpdate::doUpdate: transaction round 'RefreshLinksJob::run' already started. #0 ...\includes\deferred\DeferredUpdates.php(265): Wikimedia\Rdbms\LBFactory->beginMasterChanges(string) #1 ...\includes\deferred\DeferredUpdates.php(228): DeferredUpdates::runUpdate(MWCallableUpdate, Wikimedia\Rdbms\LBFactorySimple, integer) #2 ...\includes\deferred\DeferredUpdates.php(136): DeferredUpdates::execute(array, string, integer) #3 ...\includes\deferred\DeferredUpdates.php(95): DeferredUpdates::doUpdates(string) #4 ...\includes\deferred\DeferredUpdates.php(119): DeferredUpdates::addUpdate(MWCallableUpdate, integer) #5 ...\includes\libs\objectcache\BagOStuff.php(216): DeferredUpdates::addCallableUpdate(Closure) #6 ...\includes\libs\objectcache\BagOStuff.php(183): BagOStuff->trackDuplicateKeys(string) #7 ...\includes\parser\Preprocessor.php(110): BagOStuff->get(string) #8 ...\includes\parser\Preprocessor_DOM.php(152): Preprocessor->cacheGetTree(string, integer) #9 ...\includes\parser\Parser.php(2889): Preprocessor_DOM->preprocessToObj(string, integer) #10 ...\includes\parser\Parser.php(4121): Parser->preprocessToDom(string) #11 ...\includes\parser\Parser.php(1339): Parser->formatHeadings(string, string, boolean) #12 ...\includes\parser\Parser.php(451): Parser->internalParse(string) #13 ...\includes\StubObject.php(113): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer) #14 ...\includes\StubObject.php(139): StubObject->_call(string, array) #15 ...\includes\content\WikitextContent.php(330): StubObject->__call(string, array) #16 ...\includes\content\AbstractContent.php(497): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput) #17 ...\includes\jobqueue\jobs\RefreshLinksJob.php(227): AbstractContent->getParserOutput(Title, integer, ParserOptions, boolean) #18 ...\includes\jobqueue\jobs\RefreshLinksJob.php(122): RefreshLinksJob->runForTitle(Title) #19 ...\includes\jobqueue\JobRunner.php(289): RefreshLinksJob->run() #20 ...\includes\jobqueue\JobRunner.php(189): JobRunner->executeJob(RefreshLinksJob, Wikimedia\Rdbms\LBFactorySimple, BufferingStatsdDataFactory, integer) #21 ...\includes\MediaWiki.php(973): JobRunner->run(array) #22 ...\includes\MediaWiki.php(959): MediaWiki->triggerSyncJobs(integer, MediaWiki\Logger\LegacyLogger) #23 ...\includes\MediaWiki.php(911): MediaWiki->triggerJobs() #24 ...\includes\MediaWiki.php(731): MediaWiki->restInPeace(string) #25 ...\includes\MediaWiki.php(750): MediaWiki->{closure}() #26 ...\includes\MediaWiki.php(554): MediaWiki->doPostOutputShutdown(string) #27 ...\index.php(43): MediaWiki->run()
This may or may not be related to T154438.
SUMMARY OF T165714, T100085, and T154425
All three bugs are related to jobs (background tasks managed asynchronously) and deferred updates (also called deferrable updates, tasks postponed to the end of the request). Some deferred updates can be transformed to jobs. Jobs are usually pushed in the job queue during normal operations, but some jobs are only pushed at a latter time, these are called lazy jobs (short for lazily-pushed jobs). At the end of a MediaWiki request on the Web, deferred updates are executed, then some jobs are executed if the parameter $wgJobRunRate is not 0, and lazy jobs are pushed to the job queue.
- T165714 (duplicates: T154439) (affects: MW 1.28, 1.29, 1.30) Some jobs throw an exception when executed on the Web due to interactions between jobs and deferred updates linked to database transactions; these jobs are never executed and remain in the job queue until deleted. Bug trigerred when $wgJobRunRate > 0 (default) and the job queue is JobQueueDB (default). Fixed by https://gerrit.wikimedia.org/r/#/c/356120/ on 1.28, 1.29, 1.30.
- T100085 (duplicates: T154427) (affects: MW: 1.27, 1.28, 1.29, 1.30) Some lazy jobs added by jobs executed on the Web are not pushed and this triggers an error in the logs; these jobs are never added in the job queue, hence never executed. Bug trigerred when $wgJobRunRate > 0 (default). Fixed by https://gerrit.wikimedia.org/r/#/c/356120/ on 1.27, 1.28, 1.29, 1.30. The fix from T154425 improves the resolution. Possibly other root causes given it happened on Translatewiki and Wikimedia (where $wgJobRunRate is 0).
- T154425 (duplicates: T154438, T157679, T166867, T153849) (affects: MW 1.28, 1.29, 1.30) Some deferred updates are not executed when there exists an EnqueueableDataUpdate (a specific deferrable update, which can be transformed to a job) linked to database transactions; this happens mainly during delete, restore, move operations, possibly some others; these deferred updates are not executed. Bug trigerred when the job queue is JobQueueDB (default). Fixed by https://gerrit.wikimedia.org/r/#/c/356619/ and https://gerrit.wikimedia.org/r/#/c/357966/ in 1.28, 1.29, 1.30.