Page MenuHomePhabricator

Move action aborted by fatal error "Argument must be MediaWiki\Storage\RevisionRecord, null given"
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

Request ID: W61juwrAMGkAAHdPhScAAACK

message
PHP Fatal Error: Argument 1 passed to MediaWiki\Storage\MutableRevisionRecord::newFromParentRevision() must be an instance of MediaWiki\Storage\RevisionRecord, null given
stacktrace
#0 /srv/mediawiki/php-1.32.0-wmf.23/includes/Storage/MutableRevisionRecord.php(64): MWExceptionHandler::handleError(integer, string, string, integer, array, array)
#1 /srv/mediawiki/php-1.32.0-wmf.23/includes/Storage/RevisionStore.php(1082): MediaWiki\Storage\MutableRevisionRecord::newFromParentRevision(NULL)
#2 /srv/mediawiki/php-1.32.0-wmf.23/includes/Revision.php(1180): MediaWiki\Storage\RevisionStore->newNullRevision(Wikimedia\Rdbms\DatabaseMysqli, Title, CommentStoreComment, boolean, User)
#3 /srv/mediawiki/php-1.32.0-wmf.23/includes/MovePage.php(537): Revision::newNullRevision(Wikimedia\Rdbms\DatabaseMysqli, integer, string, boolean, User)
#4 /srv/mediawiki/php-1.32.0-wmf.23/includes/MovePage.php(271): MovePage->moveToInternal(User, Title, string, boolean, array)
#5 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMove.php(189): MovePage->move(User, string, boolean, array)
#6 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMove.php(87): ApiMove->movePage(Title, Title, string, boolean, array)
#7 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMain.php(1587): ApiMove->execute()
#8 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMain.php(531): ApiMain->executeAction()
#9 /srv/mediawiki/php-1.32.0-wmf.23/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#10 /srv/mediawiki/php-1.32.0-wmf.23/api.php(87): ApiMain->execute()

Also seen from Special:Move:

trace
reqId: W6px6ArAADwAAJ@r1lgAAACM

PHP Error: Argument 1 passed to MediaWiki\Storage\MutableRevisionRecord::newFromParentRevision() must be an instance of MediaWiki\Storage\RevisionRecord, null given

#1 /srv/mediawiki/php-1.32.0-wmf.22/includes/Storage/RevisionStore.php(1082): MediaWiki\Storage\MutableRevisionRecord::newFromParentRevision(NULL)
#2 /srv/mediawiki/php-1.32.0-wmf.22/includes/Revision.php(1180): MediaWiki\Storage\RevisionStore->newNullRevision(Wikimedia\Rdbms\DatabaseMysqli, Title, CommentStoreComment, boolean, User)
#3 /srv/mediawiki/php-1.32.0-wmf.22/includes/MovePage.php(537): Revision::newNullRevision(Wikimedia\Rdbms\DatabaseMysqli, integer, string, boolean, User)
#4 /srv/mediawiki/php-1.32.0-wmf.22/includes/MovePage.php(271): MovePage->moveToInternal(User, Title, string, boolean, array)
#5 /srv/mediawiki/php-1.32.0-wmf.22/includes/specials/SpecialMovepage.php(595): MovePage->move(User, string, boolean)
#6 /srv/mediawiki/php-1.32.0-wmf.22/includes/specials/SpecialMovepage.php(128): MovePageForm->doSubmit()
#7 /srv/mediawiki/php-1.32.0-wmf.22/includes/specialpage/SpecialPage.php(569): MovePageForm->execute(NULL)
#8 /srv/mediawiki/php-1.32.0-wmf.22/includes/specialpage/SpecialPageFactory.php(581): SpecialPage->run(NULL)
#9 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#10 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(868): MediaWiki->performRequest()
#11 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(525): MediaWiki->main()
#12 /srv/mediawiki/php-1.32.0-wmf.22/index.php(42): MediaWiki->run()

Notes

Seen over 352 times in the last few weeks. Seems to be affecting commons.wikimedia.org and ar.wikipedia.org more than other wikis, but could be a coincidence.

Event Timeline

Krinkle created this task.Sep 27 2018, 11:49 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 27 2018, 11:49 PM
Krinkle renamed this task from Move action aborted by fatal error "Argument 1 must be an instance of MediaWiki\Storage\RevisionRecord, null given" to Move action aborted by fatal error "Argument must be MediaWiki\Storage\RevisionRecord, null given".Sep 28 2018, 12:08 AM
Krinkle removed a project: MediaWiki-API.
Krinkle updated the task description. (Show Details)
Krinkle updated the task description. (Show Details)
Krinkle moved this task from Untriaged to Old on the Wikimedia-production-error board.

The relevant code in MovePage was recently touched by @Anomie in I9ebdcbc566b11dea3, but I don't see how that change could have caused this problem.

I'll change the code to handle the error more nicely and log more info, but I currently have no idea why it actually happens.

Change 464509 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Avoid fatal when finding no base revision for a null revision.

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

Change 464509 merged by jenkins-bot:
[mediawiki/core@master] Avoid fatal when finding no base revision for a null revision.

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

Status: The merged patch should fix the fatal, but replaces it with another log message and an MWException that will probably also be logged.

For the benefit of searches, those will be like "Failed to load latest revision ID $Y of page ID $X" (the logged message) and "Failed to create null revision while moving page ID $X to $TITLE" (the MWException).

I spot-checked a few of these "Failed to load latest revision ID $Y of page ID $X" errors, and in all 7 cases the revision that couldn't be loaded seems to have been a page move null-revision timestamped within a few seconds of the error message. It seems like we're running into a situation where, when a move gets double-submitted, the first submission does the move and somehow the second sees the updated page.page_latest but somehow can't load the RevisionRecord. I can't see how that would happen though.

CCicalese_WMF lowered the priority of this task from High to Medium.Nov 26 2018, 4:17 PM
CCicalese_WMF added a subscriber: CCicalese_WMF.

Reducing to normal since the fatal error is addressed. The root cause will still need to be investigated.

and somehow the second sees the updated page.page_latest but somehow can't load the RevisionRecord. I can't see how that would happen though.

A possibility would be the REPEATABLE-READ transaction isolation level MySQL uses by default. If the read of page.page_latest is done with a FOR UPDATE and the load of the RevisionRecord was hitting the "repeatable" bit, that could give this result.

Status: The merged patch should fix the fatal, but replaces it with [an] MWException that will probably also be logged.

For the benefit of searches, those will be like […] "Failed to create null revision while moving page ID $X to $TITLE".

Indeed. The fatal error is gone, but we now have a fatal exception instead. Here's a recent example as recorded in Logstash from user requests:

  • Request ID: XPfDwApAIDUAAINsMG8AAACK
  • Request URL: POST /w/api.php
message
MWException: Failed to create null revision while moving page ID … to …
trace
0 /srv/mediawiki/php-1.34.0-wmf.8/includes/MovePage.php(452): MovePage->moveToInternal(User, Title, string, boolean, array)
#1 /srv/mediawiki/php-1.34.0-wmf.8/includes/MovePage.php(262): MovePage->moveUnsafe(User, string, boolean, array)
#2 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMove.php(190): MovePage->move(User, string, boolean, array)
#3 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMove.php(87): ApiMove->movePage(Title, Title, string, boolean, array)
#4 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMain.php(1595): ApiMove->execute()
#5 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMain.php(531): ApiMain->executeAction()
#6 /srv/mediawiki/php-1.34.0-wmf.8/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#7 /srv/mediawiki/php-1.34.0-wmf.8/api.php(87): ApiMain->execute()
#8 /srv/mediawiki/w/api.php(3): include(string)

Recent weeks:

I've posted the same backtrace at T32211#5324446. Two users were moving one page at almost the same time, so I originally thought it might be just T32211: Detect conflict on move. However, @Aklapper pointed that the same backtrace is in this task, so I'm putting this info here. Have no idea if it is actually a conflict or not, might be just a coincience :).

Krinkle removed a subscriber: Krinkle.Aug 21 2019, 2:32 PM
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:08 PM
AMooney changed the task status from Open to Stalled.Mar 12 2020, 1:22 PM
Krinkle closed this task as Resolved.Apr 8 2020, 10:46 PM

When querying mediawiki-errors on Logstash now, I no longer find any matches for "must be an instance of" that relate to RevisionRecord or MutableRevisionRecord.

Aklapper removed a subscriber: Anomie.Fri, Oct 16, 5:41 PM