Page MenuHomePhabricator

Page rename (Special:MovePage) can throw InvalidArgumentException: Title does not belong to page ID X but actually belong to Y.
Open, HighPublic

Description

I noticed the following errors (and similar to) while looking at the PHP7 logs

[XMAmggpAICsAAEwlrXgAAABD] /w/index.php?title=Speciaal:PaginaHernoemen&action=submit   InvalidArgumentException from line 100 of /srv/mediawiki/php-1.34.0-wmf.1/includes/Revision/RevisionStoreRecord.php: The given Title does not belong to page ID 1284480 but actually belongs to 1280398

[XL-6RgpAAD4AAI97q5EAAADR] /w/index.php?title=Special:MovePage&action=submit   InvalidArgumentException from line 100 of /srv/mediawiki/php-1.34.0-wmf.1/includes/Revision/RevisionStoreRecord.php: The given Title does not belong to page ID 41989195 but actually belongs to 39994396

After a rough search, it looks like we have about ~3,850 of errors like these in the past 10 days

Similar tasks:

Error
  • Request ID: XO8cRQpAIDEAAL3eYJkAAACI
InvalidArgumentException: The given Title does not belong to page ID 8946238 but actually belongs to 8171110

#0 /srv/mediawiki/php-1.34.0-wmf.6/includes/Revision/RevisionStore.php(1826): MediaWiki\Revision\RevisionStoreRecord->__construct(Title, User, CommentStoreComment, stdClass, MediaWiki\Revision\RevisionSlots, boolean)
#1 /srv/mediawiki/php-1.34.0-wmf.6/includes/Revision/RevisionStore.php(2167): MediaWiki\Revision\RevisionStore->newRevisionFromRow(stdClass, integer, Title)
#2 /srv/mediawiki/php-1.34.0-wmf.6/includes/Revision/RevisionStore.php(1535): MediaWiki\Revision\RevisionStore->loadRevisionFromConds(Wikimedia\Rdbms\DBConnRef, array, integer, Title)
#3 /srv/mediawiki/php-1.34.0-wmf.6/includes/Revision.php(138): MediaWiki\Revision\RevisionStore->getRevisionByTitle(Title, integer, integer)
#4 /srv/mediawiki/php-1.34.0-wmf.6/extensions/PageImages/includes/LinksUpdateHookHandler.php(50): Revision::newFromTitle(Title)
#5 /srv/mediawiki/php-1.34.0-wmf.6/extensions/PageImages/includes/LinksUpdateHookHandler.php(74): PageImages\Hooks\LinksUpdateHookHandler->getPageImageCandidates(LinksDeletionUpdate)
#6 /srv/mediawiki/php-1.34.0-wmf.6/extensions/PageImages/includes/LinksUpdateHookHandler.php(33): PageImages\Hooks\LinksUpdateHookHandler->doLinksUpdate(LinksDeletionUpdate)
#7 /srv/mediawiki/php-1.34.0-wmf.6/includes/Hooks.php(174): PageImages\Hooks\LinksUpdateHookHandler::onLinksUpdate(LinksDeletionUpdate)
#8 /srv/mediawiki/php-1.34.0-wmf.6/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#9 /srv/mediawiki/php-1.34.0-wmf.6/includes/deferred/LinksUpdate.php(188): Hooks::run(string, array)
#10 /srv/mediawiki/php-1.34.0-wmf.6/includes/deferred/DeferredUpdates.php(274): LinksUpdate->doUpdate()
#11 /srv/mediawiki/php-1.34.0-wmf.6/includes/deferred/DeferredUpdates.php(219): DeferredUpdates::runUpdate(LinksDeletionUpdate, Wikimedia\Rdbms\LBFactoryMulti, string, integer)
#12 /srv/mediawiki/php-1.34.0-wmf.6/includes/deferred/DeferredUpdates.php(143): DeferredUpdates::execute(array, string, integer)
#13 /srv/mediawiki/php-1.34.0-wmf.6/includes/MediaWiki.php(907): DeferredUpdates::doUpdates(string)
#14 /srv/mediawiki/php-1.34.0-wmf.6/includes/MediaWiki.php(731): MediaWiki->restInPeace(string, boolean)
#15 [internal function]: Closure$MediaWiki::doPostOutputShutdown()

Details

Related Gerrit Patches:
mediawiki/core : masterRevisionStoreRecord: improve reporting of mismatching titles.
mediawiki/extensions/FlaggedRevs : masterFlaggedRevision: load revision from master when appropriate.
mediawiki/extensions/PageImages : masterUse READ_LATEST during LinksUpdate

Event Timeline

jijiki created this task.Apr 24 2019, 11:49 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 24 2019, 11:49 AM
jijiki triaged this task as Unbreak Now! priority.Apr 24 2019, 11:51 AM
jijiki updated the task description. (Show Details)
Restricted Application added subscribers: Liuxinyu970226, TerraCodes. · View Herald TranscriptApr 24 2019, 11:51 AM
jijiki updated the task description. (Show Details)Apr 24 2019, 11:52 AM
jijiki added a subscriber: Anomie.
jijiki updated the task description. (Show Details)Apr 24 2019, 1:17 PM
mobrovac lowered the priority of this task from Unbreak Now! to High.Apr 24 2019, 5:34 PM
mobrovac edited subscribers, added: daniel; removed: Anomie.
kchapman assigned this task to Anomie.Apr 26 2019, 3:18 PM
kchapman moved this task from Inbox to MCR on the Core Platform Team board.
kchapman edited projects, added Core Platform Team (MCR); removed Core Platform Team.
kchapman moved this task from Inbox to Next on the Core Platform Team Legacy board.
hashar renamed this task from Unable to move page (Special:MovePage&action=submit) to Unable to move page (Special:MovePage&action=submit) Title does not belong to page ID X but actually belong to Y.May 22 2019, 2:06 PM
Krinkle renamed this task from Unable to move page (Special:MovePage&action=submit) Title does not belong to page ID X but actually belong to Y to Page rename (Special:MovePage) can throw InvalidArgumentException: Title does not belong to page ID X but actually belong to Y..May 30 2019, 12:24 AM
Krinkle edited projects, added PageImages; removed Operations.
Krinkle updated the task description. (Show Details)

Looking through Logstash, it seems all matches for this exception message have a similar stack trace:

  • The request urls are submissions of Special:MovePage (Page rename).
  • The call sites are via PageImages\Hooks\LinksUpdateHookHandler::onLinksUpdate(LinksDeletionUpdate), as fired by the deferred LinksUpdate->doUpdate action.
Krinkle added a comment.EditedMay 30 2019, 11:06 PM

@pmiazga Could your team take a look first to confirm (or rule out) whether PageImages is using Revision::newFromTitle correctly in this context? We can also ask Core Platform to check whether MovePage is issuing the LinksDeletionUpdate incorrectly, but given no other extensions are affected looks like it might be on the PageImages side.

From a quick glance, it is constructing a Revision object by title from a replica db, which seems like it wouldn't be a reliable way to get the wikitext for the edit that just occurred, as it can both be outdated (not yet replicated) or too new (run after other page renames, and thus be updating the wrong title, leaving the one that mattered stay outdated). I would expect LinksUpdate to provide a way to get the correct Content object for your use case, although I don't know off-hand what the right method for that is.

LinksUpdate just has a ParserOutput, with no info about the revision ID or the original Content. It should probably have RenderedRevision, that would solve the problem.

sorry, I missed the ping, I'll look into it today

The LinksUpdate has two methods - setRevision() and getRevision(), the PageImages/LinksUpdateHooksHandler tries to fetch the Revision object via $linksUpdate->getRevision(). If there is no revision, it fallbacks to $rev = Revision::newFromTitle( $linksUpdate->getTitle() ); which is causing this error.

The fallback method was added in T203965: PageImages Maintenance Script finds not all Images, patch rEPIMcd2115f80d78: Reenable Indexing for Images. There is no clear information why LinksUpdate::getRevision() can return null, and using LinksUpdate::getTitle() looked like a correct way to solve that problem. IMHO, the call Revision::newFromTitle( $linksUpdate->getTitle() ) looks like a valid call, we take a Title object, and we ask for revision.

But I think I can understand why it fails, this happens as Deferred action most probably the Page is already renamed (so Title points to different page id), that's why system throws that error.

/cc @daniel @Krinkle

WDoranWMF removed Anomie as the assignee of this task.Jul 17 2019, 8:21 PM
WDoranWMF lowered the priority of this task from High to Medium.
WDoranWMF added a subscriber: Anomie.

In DeferredUpdates.log I saw the following similar error:

2019-07-25 01:21:33 [XTkEHApAIC4AACNzY80AAADA] mw1325 enwiki 1.34.0-wmf.14 DeferredUpdates ERROR: Deferred update LinksDeletionUpdate failed: The given Title does not belong to page ID 61355695 but actually belongs to 44570450 {"type":"LinksDeletionUpdate","message":"The given Title does not belong to page ID 61355695 but actually belongs to 44570450","trace":"#0 /srv/mediawiki/php-1.34.0-wmf.14/includes/Revision/RevisionStore.php(1894): MediaWiki\\Revision\\RevisionStoreRecord->__construct()

I determined that this is reproducible by moving a page over a redirect. The above DeferredUpdates.log entry occurred when I did a test move (move log entry).

I was able to reproduce this locally with PageImages and fake replication (MediaWiki sees two servers but both are really localhost). PageImages calls Revision::newFromTitle() with a Title that has the correct post-move information. RevisionStore fetches the revision information from the slave, retrieving the page and revision row for the redirect that was just deleted. The RevisionStoreRecord constructor does a sanity check, notices the mismatch, and throws an exception. So I think the solution is for PageImages to use the READ_LATEST flag.

Change 525473 had a related patch set uploaded (by Tim Starling; owner: Tim Starling):
[mediawiki/extensions/PageImages@master] Use READ_LATEST during LinksUpdate

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

Change 525473 merged by jenkins-bot:
[mediawiki/extensions/PageImages@master] Use READ_LATEST during LinksUpdate

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

WDoranWMF moved this task from MCR to mop on the Core Platform Team board.Jul 26 2019, 6:38 PM
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:07 PM

One more I have noticed today:

enwikiRevisionStoreRecord.phpThe given Title does not belong to page ID 52943292 but actually belongs to 61713901

One more I have noticed today:

enwikiRevisionStoreRecord.phpThe given Title does not belong to page ID 52943292 but actually belongs to 61713901

Can you provide a stack trace? This issue generally points towards a race condition in the context of renaming or undeletion, but it's impossible to find out what is causing it without a stack trace.

Krinkle removed a subscriber: Krinkle.Oct 8 2019, 5:14 PM

Sorry I have missed Daniel request for a stacktrace. It is lost now.

daniel closed this task as Invalid.Nov 26 2019, 5:35 PM

Closing invalid, since I can't find any instance of this error in Kibana. Please re-open with a stack trace if it happens again.

Restricted Application removed a subscriber: Liuxinyu970226. · View Herald TranscriptNov 26 2019, 5:35 PM

Sorry I have missed Daniel request for a stacktrace. It is lost now.

I note that there actually is a stack trace attached. Did I just miss that?

hashar reopened this task as Open.Nov 27 2019, 1:18 PM

That is definitely still happening:

[{exception_id}] {exception_url} InvalidArgumentException from line 99 of /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStoreRecord.php: The given Title does not belong to page ID 54440713 but actually belongs to 62426502
	1
[{exception_id}] {exception_url} InvalidArgumentException from line 99 of /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStoreRecord.php: The given Title does not belong to page ID 54441765 but actually belongs to 62426505
	1
[{exception_id}] {exception_url} InvalidArgumentException from line 99 of /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStoreRecord.php: The given Title does not belong to page ID 57535372 but actually belongs to 62426509

A trace which comes from /rpc/RunSingleJob.php

The given Title does not belong to page ID 54440713 but actually belongs to 62426502
at /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStoreRecord.php:99

#0 /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStore.php(1894): MediaWiki\Revision\RevisionStoreRecord->__construct(Title, User, CommentStoreComment, stdClass, MediaWiki\Revision\RevisionSlots, boolean)
#1 /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStore.php(1817): MediaWiki\Revision\RevisionStore->newRevisionFromRowAndSlots(stdClass, MediaWiki\Revision\RevisionSlots, integer, Title, boolean)
#2 /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStore.php(2539): MediaWiki\Revision\RevisionStore->newRevisionFromRow(stdClass, integer, Title)
#3 /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision/RevisionStore.php(1514): MediaWiki\Revision\RevisionStore->loadRevisionFromConds(Wikimedia\Rdbms\DBConnRef, array, integer, Title)
#4 /srv/mediawiki/php-1.35.0-wmf.5/includes/Revision.php(139): MediaWiki\Revision\RevisionStore->getRevisionByTitle(Title, integer, integer)
#5 /srv/mediawiki/php-1.35.0-wmf.5/includes/actions/InfoAction.php(73): Revision::newFromTitle(Title, integer, integer)
#6 /srv/mediawiki/php-1.35.0-wmf.5/includes/jobqueue/jobs/RefreshLinksJob.php(191): InfoAction::invalidateCache(Title)
#7 /srv/mediawiki/php-1.35.0-wmf.5/includes/jobqueue/jobs/RefreshLinksJob.php(126): RefreshLinksJob->runForTitle(Title)
#8 /srv/mediawiki/php-1.35.0-wmf.5/extensions/EventBus/includes/JobExecutor.php(70): RefreshLinksJob->run()
#9 /srv/mediawiki/rpc/RunSingleJob.php(76): JobExecutor->execute(array)
#10 {main}

That is definitely still happening:

Hm, my luck with logstash seems to be poor. I was unable to find matching entries. Can you point me to a query that would work, so I can figure out what I did wrong?

daniel raised the priority of this task from Medium to High.Nov 27 2019, 3:38 PM

Bumping to high, since this prevents links update jobs to run (presumably after page moves).

message:belong turns up a number of these for various code paths just within the last 15 minutes. https://logstash.wikimedia.org/goto/40f64ef65a75d7609c391dd00ef5d0bb as an example.

daniel claimed this task.Nov 27 2019, 6:41 PM

Interestingly, the stack traces vary a lot. My guess is that when a page is renamed, anything in progress that relates to that page may encounter this error. I'll have to look more closely, though.

daniel added a comment.Jan 7 2020, 7:20 PM

The instances of this I currently see on Kibana all come from FlaggedRevs:

#0 /srv/mediawiki/php-1.35.0-wmf.11/includes/Revision/RevisionStore.php(1884): MediaWiki\Revision\RevisionStoreRecord->__construct(Title, User, CommentStoreComment, stdClass, MediaWiki\Revision\RevisionSlots, boolean)
#1 /srv/mediawiki/php-1.35.0-wmf.11/includes/Revision/RevisionStore.php(1807): MediaWiki\Revision\RevisionStore->newRevisionFromRowAndSlots(stdClass, MediaWiki\Revision\RevisionSlots, integer, Title, boolean)
#2 /srv/mediawiki/php-1.35.0-wmf.11/includes/Revision.php(374): MediaWiki\Revision\RevisionStore->newRevisionFromRow(stdClass, integer, Title)
#3 /srv/mediawiki/php-1.35.0-wmf.11/extensions/FlaggedRevs/backend/FlaggedRevision.php(71): Revision->__construct(stdClass, integer, Title)
#4 /srv/mediawiki/php-1.35.0-wmf.11/extensions/FlaggedRevs/backend/FlaggedRevision.php(187): FlaggedRevision->__construct(stdClass, Title)
#5 /srv/mediawiki/php-1.35.0-wmf.11/extensions/FlaggedRevs/backend/FlaggedRevs.php(949): FlaggedRevision::newFromStable(Title, integer)
#6 /srv/mediawiki/php-1.35.0-wmf.11/extensions/FlaggedRevs/backend/FlaggedRevsHooks.php(573): FlaggedRevs::autoReviewEdit(FlaggableWikiPage, User, Revision, NULL)
#7 /srv/mediawiki/php-1.35.0-wmf.11/includes/Hooks.php(174): FlaggedRevsHooks::maybeMakeEditReviewed(WikiPage, Revision, integer, User, array)
#8 /srv/mediawiki/php-1.35.0-wmf.11/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#9 /srv/mediawiki/php-1.35.0-wmf.11/includes/Storage/PageUpdater.php(1001): Hooks::run(string, array)
#10 /srv/mediawiki/php-1.35.0-wmf.11/includes/Storage/PageUpdater.php(757): MediaWiki\Storage\PageUpdater->doModify(CommentStoreComment, User, integer)
#11 /srv/mediawiki/php-1.35.0-wmf.11/includes/page/WikiPage.php(1929): MediaWiki\Storage\PageUpdater->saveRevision(CommentStoreComment, integer)
#12 /srv/mediawiki/php-1.35.0-wmf.11/includes/EditPage.php(2352): WikiPage->doEditContent(WikitextContent, CommentStoreComment, integer, boolean, User, string, array, integer)
#13 /srv/mediawiki/php-1.35.0-wmf.11/includes/EditPage.php(1623): EditPage->internalAttemptSave(array, boolean)
#14 /srv/mediawiki/php-1.35.0-wmf.11/includes/api/ApiEditPage.php(398): EditPage->attemptSave(array)
#15 /srv/mediawiki/php-1.35.0-wmf.11/includes/api/ApiMain.php(1603): ApiEditPage->execute()
#16 /srv/mediawiki/php-1.35.0-wmf.11/includes/api/ApiMain.php(539): ApiMain->executeAction()
#17 /srv/mediawiki/php-1.35.0-wmf.11/includes/api/ApiMain.php(510): ApiMain->executeActionWithErrorHandling()
#18 /srv/mediawiki/php-1.35.0-wmf.11/api.php(78): ApiMain->execute()
#19 /srv/mediawiki/w/api.php(3): require(string)
#20 {main}

We should probably use the same approach here as for PageImages: pass the READ_LATEST flag when appropriate. FlaggedRevs actually uses such a flag already, but doesn't pass it to Revision.

Change 562590 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/extensions/FlaggedRevs@master] FlaggedRevision: load revision from master when appropriate.

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

Change 562591 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] RevisionStoreRecord: improve reporting of mismatching titles.

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

Change 562591 merged by jenkins-bot:
[mediawiki/core@master] RevisionStoreRecord: improve reporting of mismatching titles.

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

brennen added a subscriber: brennen.

Seeing a number of these from 1.35.0-wmf.15:

reqId: XidtzApAMDkAAFHdlf4AAAIF
server: ar.wikipedia.org
timestamp: 2020-01-21T21:32:04+00:00
url: /w/api.php?format=xml&rawcontinue=1&maxlag=5&action=edit

InvalidArgumentException from line 99 of /srv/mediawiki/php-1.35.0-wmf.15/includes/Revision/RevisionStoreRecord.php: The given Title (علاقات الجبل الأسود الخارجية) does not belong to page ID 7103929 but actually belongs to 7103918
#0 /srv/mediawiki/php-1.35.0-wmf.15/includes/Revision/RevisionStore.php(1885): MediaWiki\Revision\RevisionStoreRecord->__construct(Title, User, CommentStoreComment, stdClass, MediaWiki\Revision\RevisionSlots, boolean)
#1 /srv/mediawiki/php-1.35.0-wmf.15/includes/Revision/RevisionStore.php(1808): MediaWiki\Revision\RevisionStore->newRevisionFromRowAndSlots(stdClass, MediaWiki\Revision\RevisionSlots, integer, Title, boolean)
#2 /srv/mediawiki/php-1.35.0-wmf.15/includes/Revision.php(374): MediaWiki\Revision\RevisionStore->newRevisionFromRow(stdClass, integer, Title)
#3 /srv/mediawiki/php-1.35.0-wmf.15/extensions/FlaggedRevs/backend/FlaggedRevision.php(71): Revision->__construct(stdClass, integer, Title)
#4 /srv/mediawiki/php-1.35.0-wmf.15/extensions/FlaggedRevs/backend/FlaggedRevision.php(187): FlaggedRevision->__construct(stdClass, Title)
#5 /srv/mediawiki/php-1.35.0-wmf.15/extensions/FlaggedRevs/backend/FlaggedRevs.php(949): FlaggedRevision::newFromStable(Title, integer)
#6 /srv/mediawiki/php-1.35.0-wmf.15/extensions/FlaggedRevs/backend/FlaggedRevsHooks.php(573): FlaggedRevs::autoReviewEdit(FlaggableWikiPage, User, Revision, NULL)
#7 /srv/mediawiki/php-1.35.0-wmf.15/includes/Hooks.php(174): FlaggedRevsHooks::maybeMakeEditReviewed(WikiPage, Revision, integer, User, array)
#8 /srv/mediawiki/php-1.35.0-wmf.15/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#9 /srv/mediawiki/php-1.35.0-wmf.15/includes/Storage/PageUpdater.php(1001): Hooks::run(string, array)
#10 /srv/mediawiki/php-1.35.0-wmf.15/includes/Storage/PageUpdater.php(757): MediaWiki\Storage\PageUpdater->doModify(CommentStoreComment, User, integer)
#11 /srv/mediawiki/php-1.35.0-wmf.15/includes/page/WikiPage.php(1930): MediaWiki\Storage\PageUpdater->saveRevision(CommentStoreComment, integer)
#12 /srv/mediawiki/php-1.35.0-wmf.15/includes/EditPage.php(2352): WikiPage->doEditContent(WikitextContent, CommentStoreComment, integer, boolean, User, string, array, integer)
#13 /srv/mediawiki/php-1.35.0-wmf.15/includes/EditPage.php(1623): EditPage->internalAttemptSave(array, boolean)
#14 /srv/mediawiki/php-1.35.0-wmf.15/includes/api/ApiEditPage.php(398): EditPage->attemptSave(array)
#15 /srv/mediawiki/php-1.35.0-wmf.15/includes/api/ApiMain.php(1603): ApiEditPage->execute()
#16 /srv/mediawiki/php-1.35.0-wmf.15/includes/api/ApiMain.php(539): ApiMain->executeAction()
#17 /srv/mediawiki/php-1.35.0-wmf.15/includes/api/ApiMain.php(510): ApiMain->executeActionWithErrorHandling()
#18 /srv/mediawiki/php-1.35.0-wmf.15/api.php(78): ApiMain->execute()
#19 /srv/mediawiki/w/api.php(3): require(string)
#20 {main}
brennen moved this task from Backlog to Logs/Train on the User-brennen board.Jan 21 2020, 10:07 PM