Page MenuHomePhabricator

Wikimedia\Assert\PreconditionException: Precondition failed: page must exist
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\PreconditionException: Precondition failed: page must exist
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.2/vendor/wikimedia/assert/src/Assert.php(49)
#0/srv/mediawiki/php-1.44.0-wmf.2/extensions/CirrusSearch/includes/Updater.php(252)Wikimedia\Assert\Assert::precondition(bool, string)
#1/srv/mediawiki/php-1.44.0-wmf.2/extensions/CirrusSearch/includes/Updater.php(283)CirrusSearch\Updater->updateWeightedTags(MediaWiki\Page\PageIdentityValue, string, array, string)
#2/srv/mediawiki/php-1.44.0-wmf.2/extensions/GrowthExperiments/includes/NewcomerTasks/AddLink/LinkRecommendationHelper.php(100)CirrusSearch\Updater->resetWeightedTags(MediaWiki\Page\PageIdentityValue, array, string)
#3/srv/mediawiki/php-1.44.0-wmf.2/includes/deferred/MWCallableUpdate.php(52)GrowthExperiments\NewcomerTasks\AddLink\LinkRecommendationHelper->GrowthExperiments\NewcomerTasks\AddLink\{closure}(string)
#4/srv/mediawiki/php-1.44.0-wmf.2/includes/deferred/DeferredUpdates.php(460)MediaWiki\Deferred\MWCallableUpdate->doUpdate()
#5/srv/mediawiki/php-1.44.0-wmf.2/includes/deferred/DeferredUpdates.php(204)MediaWiki\Deferred\DeferredUpdates::attemptUpdate(MediaWiki\Deferred\MWCallableUpdate)
#6/srv/mediawiki/php-1.44.0-wmf.2/includes/deferred/DeferredUpdates.php(291)MediaWiki\Deferred\DeferredUpdates::run(MediaWiki\Deferred\MWCallableUpdate)
#7/srv/mediawiki/php-1.44.0-wmf.2/includes/deferred/DeferredUpdatesScope.php(243)MediaWiki\Deferred\DeferredUpdates::MediaWiki\Deferred\{closure}(MediaWiki\Deferred\MWCallableUpdate, int)
#8/srv/mediawiki/php-1.44.0-wmf.2/includes/deferred/DeferredUpdatesScope.php(172)MediaWiki\Deferred\DeferredUpdatesScope->processStageQueue(int, int, Closure)
#9/srv/mediawiki/php-1.44.0-wmf.2/includes/deferred/DeferredUpdates.php(310)MediaWiki\Deferred\DeferredUpdatesScope->processUpdates(int, Closure)
#10/srv/mediawiki/php-1.44.0-wmf.2/includes/MediaWikiEntryPoint.php(674)MediaWiki\Deferred\DeferredUpdates::doUpdates()
#11/srv/mediawiki/php-1.44.0-wmf.2/includes/MediaWikiEntryPoint.php(496)MediaWiki\MediaWikiEntryPoint->restInPeace()
#12/srv/mediawiki/php-1.44.0-wmf.2/includes/MediaWikiEntryPoint.php(454)MediaWiki\MediaWikiEntryPoint->doPostOutputShutdown()
#13/srv/mediawiki/php-1.44.0-wmf.2/includes/MediaWikiEntryPoint.php(209)MediaWiki\MediaWikiEntryPoint->postOutputShutdown()
#14/srv/mediawiki/php-1.44.0-wmf.2/index.php(58)MediaWiki\MediaWikiEntryPoint->run()
#15/srv/mediawiki/w/index.php(3)require(string)
#16{main}
Notes

522 of these in logs, all for 1.44.0-wmf.2 (T375661). Big initial spike, intermittent since then:

2024-11-13-15:30:49.png (252×634 px, 15 KB)

Details

Request URL
https://pl.wikipedia.org/w/index.php?action=submit&title=*

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This is strange. This covered the time when T378983: Add Link recommendation are not being processed by CirrusSearch (November 2024) was acute. But from

2024-11-13-15:30:49.png (252×634 px, 15 KB)
it looks like the spike was on the 11th of November? That would be just before we tried reenabling the new system in CirrusSearch: re-enable offloading weighted tags via EventBus.

The error-message itself sounds like we maybe need to add special handling for a page being move or a page being deleted or something like that?

CC @Urbanecm_WMF

I checked a couple of the errors, and all were related to newly created pages. I think this was caused by us switching the wgGETempLinkRecommendationSwitchTagClearHook flag to true (SAL). In that deployment, we started to call WeightedTagsUpdater::resetWeightedTags as part of onPageSaveComplete. The problem is that onPageSaveComplete runs right after the page was created. Because of that, it wouldn't be surprising if certain parts of MediaWiki did not yet realise the page actually exists.

Given the purpose of the hook is to invalidate the Add-Link weighted tag if is present in the search index, we can just stop running the hook if the page is freshly created (the only way how the weighted tag could get to the search index is by GrowthExperiments calling WeightedTagsUpdater::updateWeightedTags, and the only way how that could happen is if the page exists already, which it didn't, as it is just getting created). That way, we can avoid figuring out how to get the valid ID (preventing ourselves from getting into a similar rabbit hole like T380500).

The good question is how would we detect whether the page is getting created. I can't see any param that would inform us of that. Maybe this is something DomainEvent could help us with (T380505)? Unlike onPageSaveComplete's signature, PageUpdatedEvent allows subscribers to determine whether they're working with a very first edit on a page (among other things, it provides getOldRevision (which can be null if there is no previous revision).

As of now, the errors aren't getting logged, but that is because EventBusWeightedTagsUpdater (the implementation we use since T378983) does not have a precondition of "the updated page exists". Regardless of whether the errors are getting logged or not, I think it makes sense to not run WeightedTagsUpdater::resetWeightedTags if there is nothing to reset (=for fresh pages), and I think that should be a simple enough change to make as part of bugfixing. Moving to sprint (but other Growth engineers should feel free to unsprintize it if they disagree or if it turns to be a lot of additional effort).

So, your suggestion is to fix this by also doing T380505? That sounds good to me 👍

Sgs triaged this task as Medium priority.Nov 27 2024, 5:17 PM
KStoller-WMF subscribed.

Moving this to blocked by: T379838

Change #1117544 had a related patch set uploaded (by Michael Große; author: Michael Große):

[mediawiki/extensions/GrowthExperiments@master] fix(AddLink): Don't try to clear recommendations for new page

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

Change #1117544 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] fix(AddLink): Don't try to clear recommendations for new page

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

QA Note: Not really something to test here beyond asserting that this error no longer occurs in logstash after this change arrives on Group 2 on Thursday, February 2oth. This error is logged in a deferred update after a new page was created, no user-visible impact.

Etonkovidova subscribed.

Checked for group 2 (wmf.17` - the error is not present.