Page MenuHomePhabricator

CheckUser opens DB master connection when email is sent
Closed, ResolvedPublic

Description

This causes masterConn warnings in other places, like:

 Expectation (masterConns <= 0) by SpecialPageFactory::executePath not met:
[connect to 10.64.16.7 (nlwiki)]
#0 /srv/mediawiki/php-1.29.0-wmf.7/includes/libs/rdbms/TransactionProfiler.php(160): TransactionProfiler->reportExpectationViolated()
#1 /srv/mediawiki/php-1.29.0-wmf.7/includes/libs/rdbms/loadbalancer/LoadBalancer.php(590): TransactionProfiler->recordConnection()
#2 /srv/mediawiki/php-1.29.0-wmf.7/includes/GlobalFunctions.php(3081): LoadBalancer->getConnection()
#3 /srv/mediawiki/php-1.29.0-wmf.7/extensions/CheckUser/CheckUser.hooks.php(161): wfGetDB()
#4 /srv/mediawiki/php-1.29.0-wmf.7/includes/Hooks.php(195): CheckUserHooks::updateCUEmailData()
#5 /srv/mediawiki/php-1.29.0-wmf.7/extensions/ContactPage/ContactPage_body.php(409): Hooks::run()
#6 /srv/mediawiki/php-1.29.0-wmf.7/includes/htmlform/HTMLForm.php(662): SpecialContact->processInput()
#7 /srv/mediawiki/php-1.29.0-wmf.7/includes/htmlform/HTMLForm.php(554): HTMLForm->trySubmit()
#8 /srv/mediawiki/php-1.29.0-wmf.7/includes/htmlform/HTMLForm.php(569): HTMLForm->tryAuthorizedSubmit()
#9 /srv/mediawiki/php-1.29.0-wmf.7/extensions/ContactPage/ContactPage_body.php(229): HTMLForm->show()
#10 /srv/mediawiki/php-1.29.0-wmf.7/includes/specialpage/SpecialPage.php(522): SpecialContact->execute()
#11 /srv/mediawiki/php-1.29.0-wmf.7/includes/specialpage/SpecialPageFactory.php(577): SpecialPage->run()
#12 /srv/mediawiki/php-1.29.0-wmf.7/includes/MediaWiki.php(283): SpecialPageFactory::executePath()
#13 /srv/mediawiki/php-1.29.0-wmf.7/includes/MediaWiki.php(858): MediaWiki->performRequest()
#14 /srv/mediawiki/php-1.29.0-wmf.7/includes/MediaWiki.php(519): MediaWiki->main()
#15 /srv/mediawiki/php-1.29.0-wmf.7/index.php(43): MediaWiki->run()
#16 /srv/mediawiki/w/index.php(3): include()
#17 {main}

In this case, SpecialContact is a special page that's not marked as doing writes, and so SpeicalPageFactory imposes the expectation that no master connection will be opened (despite the fact that this was a POST request). SpecialContact doesn't try to do any writes, but it sends email and runs the EmailUser hook, and CheckUser hooks into that and performs a DB write.

I'm guessing we should defer the write in updateCUEmailData() maybe? But I'm not sure.

Event Timeline

Catrope created this task.Jan 6 2017, 6:34 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 6 2017, 6:34 PM

Change 330968 had a related patch set uploaded (by Catrope):
Defer the DB write in updateCUEmailData

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

Catrope updated the task description. (Show Details)Jan 6 2017, 6:49 PM

Change 330968 merged by jenkins-bot:
Defer the DB write in updateCUEmailData

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

Huji closed this task as Resolved.Aug 28 2017, 12:33 PM
Huji claimed this task.
Huji removed a project: Patch-For-Review.