In T199699: PageTriage performs unexpected db writes on GET request (TransactionProfiler warning from ArticleCompileProcessor) and T154719: PageTriage opens master connection on GET for ArticleMetadata cache misses we made some changes to prevent writes and master connections on GET requests. However looks like we missed one: rollbacks of edits are done via a GET request, and that triggers onLinksUpdateComplete which then compiles metadata. Example:
Expectation (writes <= 0) by MediaWiki::restInPeace not met (actual: 29):
query-m: UPDATE `pagetriage_page` SET ptrp_tags_updated = 'X' [TRX#d51b24]
#0 /srv/mediawiki/php-1.32.0-wmf.18/includes/libs/rdbms/TransactionProfiler.php(224): Wikimedia\Rdbms\TransactionProfiler->reportExpectationViolated()
#1 /srv/mediawiki/php-1.32.0-wmf.18/includes/libs/rdbms/database/Database.php(1246): Wikimedia\Rdbms\TransactionProfiler->recordQueryCompletion()
#2 /srv/mediawiki/php-1.32.0-wmf.18/includes/libs/rdbms/database/Database.php(1143): Wikimedia\Rdbms\Database->doProfiledQuery()
#3 /srv/mediawiki/php-1.32.0-wmf.18/includes/libs/rdbms/database/Database.php(2062): Wikimedia\Rdbms\Database->query()
#4 /srv/mediawiki/php-1.32.0-wmf.18/extensions/PageTriage/includes/PageTriage.php(164): Wikimedia\Rdbms\Database->update()
#5 /srv/mediawiki/php-1.32.0-wmf.18/extensions/PageTriage/includes/ArticleCompile/ArticleCompileProcessor.php(267): MediaWiki\Extension\PageTriage\PageTriage->update()
#6 /srv/mediawiki/php-1.32.0-wmf.18/extensions/PageTriage/includes/ArticleCompile/ArticleCompileProcessor.php(133): MediaWiki\Extension\PageTriage\ArticleCompile\ArticleCompileProcessor->save()
#7 /srv/mediawiki/php-1.32.0-wmf.18/extensions/PageTriage/includes/Hooks.php(200): MediaWiki\Extension\PageTriage\ArticleCompile\ArticleCompileProcessor->compileMetadata()
#8 /srv/mediawiki/php-1.32.0-wmf.18/includes/deferred/MWCallableUpdate.php(34): Closure$MediaWiki\Extension\PageTriage\Hooks::onLinksUpdateComplete()
#9 /srv/mediawiki/php-1.32.0-wmf.18/includes/deferred/DeferredUpdates.php(268): MWCallableUpdate->doUpdate()
#10 /srv/mediawiki/php-1.32.0-wmf.18/includes/deferred/DeferredUpdates.php(226): DeferredUpdates::runUpdate()
#11 /srv/mediawiki/php-1.32.0-wmf.18/includes/deferred/DeferredUpdates.php(134): DeferredUpdates::execute()
#12 /srv/mediawiki/php-1.32.0-wmf.18/includes/MediaWiki.php(914): DeferredUpdates::doUpdates()
#13 /srv/mediawiki/php-1.32.0-wmf.18/includes/MediaWiki.php(734): MediaWiki->restInPeace()
#14 (): Closure$MediaWiki::doPostOutputShutdown()
#15 {main}referrer is https://en.wikipedia.org/w/index.php?title=D.K.&action=history and URL is /w/index.php?title=D.K.&action=rollback&from=Bollywood+Filmies&token={redacted}
Oddly, when I do a rollback action locally and log the request method in onLinksUpdateComplete, MediaWiki tells me it's a POST request so I'm unable to reproduce this.
One solution would be to wrap the deferred update in onLinksUpdateComplete() with a check for whether the request is a POST, and if not, use the job queue to get the metadata compiled at a later time. Not ideal since that could happen several hours after the request, but not sure what other options we have in this scenario.