Page MenuHomePhabricator

PHPDBG / DBUnexpectedError .. AtomicSectionUpdate::doUpdate: Flush failed ... Cannot COMMIT ...
Closed, ResolvedPublic

Description

Some enlightenment would be nice on what (or better why) "DBUnexpectedError from line 2826 of ...\mw-master\includes\libs\rdbms\database\Database.php: AtomicSectionUpdate::doUpdate: Cannot COMMIT to clear snapshot because writes are pending" is raised to understand the limitations when using PHPDBG [0, 1] in connection with MW.

  • What causes the "AtomicSectionUpdate::doUpdate: Cannot COMMIT..."?
  • What actions can be taken to avoid "... Cannot COMMIT ..."?
  • What does snapshot mean in the given context? The message of " ... Cannot COMMIT to clear snapshot .." seems a bit ambiguous.

Stack

Running with phpdbg on:

MediaWiki 1.28.0-alpha (84f96de)
PHP 7.0.2 (apache2handler)
MariaDB 10.1.9-MariaDB

> phpdbg -qrr ../../tests/phpunit/phpunit.php -c phpunit.xml.dist
Using PHP 7.0.2

Semantic MediaWiki: 2.5.0-alpha (SMWSQLStore3, mysql)
MediaWiki:          1.28.0-alpha (MediaWiki vendor autoloader)
Site language:      en

Execution time:     2016-10-10 12:36
Xdebug:             Disabled (or not installed)

PHPUnit 4.8.24 by Sebastian Bergmann and contributors.

Runtime:        PHPDBG 7.0.2
Configuration:  ...\mw-master\extensions\SemanticMediaWiki\phpunit.xml.dist

.............................................................   61 / 4106 (  1%)
.............................................................  122 / 4106 (  2%)
.....................................
...
CloneDatabase::cloneTableStructure duplicating user_properties to unittest_user_properties
CloneDatabase::cloneTableStructure dropping unittest_valid_tag
CloneDatabase::cloneTableStructure duplicating valid_tag to unittest_valid_tag
CloneDatabase::cloneTableStructure dropping unittest_watchlist
CloneDatabase::cloneTableStructure duplicating watchlist to unittest_watchlist
[StashEdit] Empty cache for key 'mw-master:prepared-edit:1bfa43f59684425a7705634c29384f8c:298750bd1e455195c6391eb16753a726193d9470:90f42dc8c99187877261a42fd0a194b3' ('SMWUTDummyPage'); user '127.0.0.1'.
[smw] Clear CachedPropertyValuesPrefetcher for SMWUTDummyPage#0#
[objectcache] Rejected set() for mw-master:page-restrictions:1:1 due to pending writes.
Title::getRestrictionTypes: applicable restrictions to [[SMWUTDummyPage]] are {edit,move}
User::getBlockedStatus: checking...
[objectcache] Rejected set() for mw-master:page-restrictions:1:1 due to pending writes.
Title::getRestrictionTypes: applicable restrictions to [[SMWUTDummyPage]] are {edit,move}
User::getBlockedStatus: checking...
[exception] [31c616c417d0db24c5ad711b] [no req]   DBUnexpectedError from line 2826 of ...\mw-master\includes\libs\rdbms\database\Database.php: AtomicSectionUpdate::doUpdate: Cannot COMMIT to clear snapshot because writes are pending (DatabaseMysqlBase::duplicateTableStructure, DatabaseMysqlBase::duplicateTableStructure, DatabaseMysqlBase::duplicateTableStructure, DatabaseMysqlBase::duplicateTableStructure, DatabaseMysqlBase::duplicateTableStructure, 
...
#0 ...\mw-master\includes\libs\rdbms\loadbalancer\LoadBalancer.php(1083): Database->flushSnapshot(string)
#1 ...\mw-master\includes\libs\rdbms\loadbalancer\LoadBalancer.php(1381): LoadBalancer->{closure}(DatabaseMysqli)
#2 ...\mw-master\includes\libs\rdbms\loadbalancer\LoadBalancer.php(1090): LoadBalancer->forEachOpenMasterConnection(Closure)
#3 ...\mw-master\includes\libs\rdbms\lbfactory\LBFactory.php(177): LoadBalancer->beginMasterChanges(string)
#4 ...\mw-master\includes\libs\rdbms\lbfactory\LBFactorySimple.php(145): LBFactory->{closure}(LoadBalancer, string, array)
#5 ...\mw-master\includes\libs\rdbms\lbfactory\LBFactory.php(179): LBFactorySimple->forEachLB(Closure, array)
#6 ...\mw-master\includes\libs\rdbms\lbfactory\LBFactory.php(201): LBFactory->forEachLBCallMethod(string, array)
#7 ...\mw-master\includes\deferred\DeferredUpdates.php(246): LBFactory->beginMasterChanges(string)
#8 ...\mw-master\includes\deferred\DeferredUpdates.php(209): DeferredUpdates::runUpdate(AtomicSectionUpdate, LBFactorySimple, integer)
#9 ...\mw-master\includes\deferred\DeferredUpdates.php(121): DeferredUpdates::execute(array, string, integer)

PS: Running the tests on a "normal" PHP 7.0.11 with Xdebug 2.4.1 works just fine.

[0] http://phpdbg.com/docs
[1] https://thephp.cc/news/2015/08/phpunit-4-8-code-coverage-support

Event Timeline

I would really appreciate some feedback (or at least some form of acknowledgement) on mentioned questions.

"Clearing the snapshot" just means committing any open transaction so that any REPEATABLE-READ snapshot of the data is reset to the latest data on that DB. If deferred updates run while a transaction with writes is still uncommitted, this cannot be done without committing the transaction (possible halfway-through), so it gives an error.

Could be an explicit DeferredUpdates::doUpdates() call in a bad place.

Only an idea (I have not tested this specific case), but given you use PHPDBG there could be differences with CLI (the “normal” command line PHP). Comparing with the list on T162591, there are many occurrences of CLI-specific cases around Database and LBFactory, so you could try to replace conditions (PHP_SAPI === 'cli') by (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') and possibly it will solve this bug.

Krinkle claimed this task.
Krinkle moved this task from Usage problem to Rdbms library on the MediaWiki-libs-Rdbms board.
Krinkle subscribed.

Questions to help resolve the SMW issue were answered by @aaron two comments up.

Krinkle added a project: Performance-Team.