Page MenuHomePhabricator

Avoid opening master db connection on special pages (e.g. Special:NewItem) when not needed
Closed, ResolvedPublic


Not quite sure what is going on here, from the logs:

2015-03-26 14:24:44 mw1032 wikidatawiki: Expectation (masterConns <= 0) by MediaWiki::main not met:
[connect to (wikidatawiki)]
TransactionProfiler.php line 254 calls wfBacktrace()
TransactionProfiler.php line 112 calls TransactionProfiler->reportExpectationViolated()
LoadBalancer.php line 517 calls TransactionProfiler->recordConnection()
GlobalFunctions.php line 3641 calls LoadBalancer->getConnection()
SqlStore.php line 460 calls wfGetDB()
SqlStore.php line 542 calls Wikibase\SqlStore->newIdGenerator()
SqlStore.php line 531 calls Wikibase\SqlStore->newEntityStore()
WikibaseRepo.php line 316 calls Wikibase\SqlStore->getEntityStore()
SpecialWikibaseRepoPage.php line 83 calls Wikibase\Repo\WikibaseRepo->getEntityStore()
SpecialNewEntity.php line 64 calls Wikibase\Repo\Specials\SpecialWikibaseRepoPage->construct()
SpecialNewItem.php line 34 calls Wikibase\Repo\Specials\SpecialNewEntity->
SpecialPageFactory.php line 409 calls Wikibase\Repo\Specials\SpecialNewItem->__construct()
SpecialPageFactory.php line 537 calls SpecialPageFactory::getPage()
MediaWiki.php line 268 calls SpecialPageFactory::executePath()
MediaWiki.php line 571 calls MediaWiki->performRequest()
MediaWiki.php line 422 calls MediaWiki->main()
index.php line 46 calls MediaWiki->run()
index.php line 3 calls include()


Related Gerrit Patches:
mediawiki/extensions/Wikibase : masterLazy initialize db connection in SqlIdGenerator

Event Timeline

aaron created this task.Mar 26 2015, 2:46 PM
aaron claimed this task.
aaron removed aaron as the assignee of this task.
aaron raised the priority of this task from to Medium.
aaron updated the task description. (Show Details)
aaron set Security to None.
aaron added subscribers: aaron, Aklapper, bd808 and 5 others.

No, that's just phab carrying over parent tags.

Lydia_Pintscher added subscribers: JanZerebecki, hoo.
aude claimed this task.Apr 7 2015, 10:20 AM
aude renamed this task from SpecialNewEntity needing the master on GET/HEAD? to Avoid opening master db connection on special pages (e.g. Special:NewItem) when not needed.Apr 7 2015, 1:23 PM
aude added a comment.Apr 7 2015, 1:26 PM

this happens not just on Special:NewEntity, but as well Special:NewProperty, SetLabel, etc.

the fix will apply to all these cases and generally for anything that uses SqlIdGenerator.

Options include:

  • extend DBAccess in core, which allows to lazy initialize. (though would prefer to have DBAccess as a constructor param / member variable that we can mock)
  • put LoadBalancer param in the constructor instead of DatabaseBase, which allows to lazy initialize
  • have some other DBAccess object that is non-abstract that we can put in the constructor.
aaron added a comment.Apr 7 2015, 5:33 PM

getLazyConnectionRef() might be useful, though it can through off type-hinting/IDEs for the moment

Change 203353 had a related patch set uploaded (by Aude):
Lazy initialize db connection in SqlIdGenerator

aude moved this task from Doing to Review on the Wikidata-Sprint-2015-04-07 board.Apr 14 2015, 6:31 AM

Change 203353 merged by jenkins-bot:
Lazy initialize db connection in SqlIdGenerator

aude closed this task as Resolved.Apr 15 2015, 7:52 AM
aude moved this task from Review to Done on the Wikidata-Sprint-2015-04-07 board.