Page MenuHomePhabricator

Edit fails with fatal IncompleteRevisionException: rev_page field must not be 0
Closed, ResolvedPublicPRODUCTION ERROR

Description

Impact

Unable to save certain edits.

Notes

Logs so far indicate it affects both Wikimedia Commons and Meta-Wiki. It was not seen before this week.

Error
normalized_message
[{reqId}] {exception_url}   MediaWiki\Revision\IncompleteRevisionException: rev_page field must not be 0!
exception.trace
from /srv/mediawiki/php-1.39.0-wmf.4/includes/Revision/RevisionStore.php(417)
#0 /srv/mediawiki/php-1.39.0-wmf.4/includes/Revision/RevisionStore.php(478): MediaWiki\Revision\RevisionStore->failOnEmpty(integer, string)
#1 /srv/mediawiki/php-1.39.0-wmf.4/includes/Storage/PageUpdater.php(1332): MediaWiki\Revision\RevisionStore->insertRevisionOn(MediaWiki\Revision\MutableRevisionRecord, Wikimedia\Rdbms\DBConnRef)
#2 /srv/mediawiki/php-1.39.0-wmf.4/includes/Storage/PageUpdater.php(909): MediaWiki\Storage\PageUpdater->doModify(CommentStoreComment)
#3 /srv/mediawiki/php-1.39.0-wmf.4/includes/EditPage.php(2378): MediaWiki\Storage\PageUpdater->saveRevision(CommentStoreComment, integer)
#4 /srv/mediawiki/php-1.39.0-wmf.4/includes/EditPage.php(1694): EditPage->internalAttemptSave(array, boolean, boolean)
#5 /srv/mediawiki/php-1.39.0-wmf.4/includes/EditPage.php(650): EditPage->attemptSave(array)
#6 /srv/mediawiki/php-1.39.0-wmf.4/includes/actions/EditAction.php(71): EditPage->edit()
#7 /srv/mediawiki/php-1.39.0-wmf.4/includes/actions/SubmitAction.php(38): EditAction->show()
#8 /srv/mediawiki/php-1.39.0-wmf.4/includes/MediaWiki.php(545): SubmitAction->show()
#9 /srv/mediawiki/php-1.39.0-wmf.4/includes/MediaWiki.php(321): MediaWiki->performAction(Article, Title)
#10 /srv/mediawiki/php-1.39.0-wmf.4/includes/MediaWiki.php(911): MediaWiki->performRequest()
#11 /srv/mediawiki/php-1.39.0-wmf.4/includes/MediaWiki.php(565): MediaWiki->main()
#12 /srv/mediawiki/php-1.39.0-wmf.4/index.php(53): MediaWiki->run()
#13 /srv/mediawiki/php-1.39.0-wmf.4/index.php(46): wfIndexMain()
#14 /srv/mediawiki/w/index.php(3): require(string)
#15 {main}

Details

Request URL
https://commons.wikimedia.org/w/index.php?title=Module:Statement/sandbox&action=submit

Event Timeline

Might be related to an overly long edit summary I was trying to write; this edit worked fine.

(Might not even be due to the train, that’s just my assumption for now because editing the module worked fine before wmf.4 as far as I can tell.)

I was eventually able to save my edit, with the same module contents and edit summary as before; I’m not sure what I did differently. (I thought it might be related to using the “preview page with this template” feature, but I tried that theory on the sandbox testcases and was still able to save an edit after doing the preview.)

Krinkle renamed this task from IncompleteRevisionException trying to save a module edit on Commons to Commons edit fails with fatal IncompleteRevisionException: rev_page field must not be 0.Mar 23 2022, 10:37 PM
Krinkle triaged this task as High priority.
Krinkle updated the task description. (Show Details)
Krinkle moved this task from Untriaged to Mar 2022 on the Wikimedia-production-error board.

Logs so far indicate it affects both Wikimedia Commons and Meta-Wiki.

There are no matches for IncompleteRevisionException before this week.

\cc @daniel as this related to RevisionStore.

I'm only seeing this happen six times, for two pages, and some of these are probably from testing this bug: https://logstash.wikimedia.org/goto/50158d41d93177870d413004aa883783

Given the low frequency and intermediate nature of this issue, perhaps it doesn't have to block the train? We'd want someone (tm) to commit to fixing it, though.

It seems to me like the 0 page ID would have to come from PageUpdater::makeNewRevision, when it calls $rev->setPageId( $title->getArticleID() ). Perhaps this should do READ_FROM_MASTER? Though in this case, the page isn't new, that shouldn't be the issue.

I shared Lucas' suspicion that this is related to the "preview page with this template" feature, but I don't know how. PageEditStash comes to mind as a mechanism that would allow a zero page ID from a fake revision to propagate to the request that would actually try to save the edit. But again, I don't see how...

I maybe experience the same issue.

I try to add the French translation of the string "usage history (main statement)" in Module:I18n/property documentation, but when I want to save the page, I get this message:
: Internal error
: [5ca0045f-2e36-45a0-8bac-61190a8ec885] 2022-03-28 08:04:08: Fatal exception of type "MediaWiki\Revision\IncompleteRevisionException".

Ammarpad renamed this task from Commons edit fails with fatal IncompleteRevisionException: rev_page field must not be 0 to Edit fails with fatal IncompleteRevisionException: rev_page field must not be 0.Mar 30 2022, 5:04 PM

It seems to me like the 0 page ID would have to come from PageUpdater::makeNewRevision, when it calls $rev->setPageId( $title->getArticleID() ). Perhaps this should do READ_FROM_MASTER? Though in this case, the page isn't new, that shouldn't be the issue.

I shared Lucas' suspicion that this is related to the "preview page with this template" feature, but I don't know how. PageEditStash comes to mind as a mechanism that would allow a zero page ID from a fake revision to propagate to the request that would actually try to save the edit. But again, I don't see how...

I can confirm that this is happening as I did some adhoc debugging on a page on test wiki

https://github.com/wikimedia/mediawiki/blob/wmf/1.39.0-wmf.5/includes/Storage/PageUpdater.php#L1151

$rev->setPageId( $title->getArticleID() );

When making an edit on this page https://test.wikipedia.org/wiki/Module:Sandbox/Keyacom/color/v2
With a blank summary, $title->getArticleID() returns 0
With a non blank summary $title->getArticleID() returns 125460

PageEditStash comes to mind as a mechanism that would allow a zero page ID from a fake revision to propagate to the request that would actually try to save the edit. But again, I don't see how...

I'm highly suspicious of stashes too now

Again using https://test.wikipedia.org/wiki/Module:Sandbox/Keyacom/color/v2

I can get a stacktrace if I

  • click edit
  • change the text
  • click save

I can save without a summary if I

  • click edit
  • change the text
  • enter a summary in the box
  • (wait for it to stash, you can click out of the box to make this happen)
  • blank the summary in the box
  • click save

So my conclusion would be that saving only works for this page IF a stash runs before you hit the save button save?

With further testing on https://test.wikipedia.org/wiki/Module:Sandbox/Keyacom/color/TEST I managed to also then confirm this only happens when the page being edited has a sub page.

So when editing https://test.wikipedia.org/wiki/Module:Sandbox/Keyacom/color/TEST, if the https://test.wikipedia.org/wiki/Module:Sandbox/Keyacom/color/TEST/doc page exists edits using the reproduction above will fail.
If the /doc page does not exist, edits will succeed.

Change 775807 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Use page ID from parent revision, improve logging.

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

Change 775807 merged by jenkins-bot:

[mediawiki/core@master] Use page ID from parent revision, improve logging.

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

I tested this patch on mwdebug1001 with my reproduction case and it indeed seem to fix the issue :)
I made the following revision with the fix applied https://test.wikipedia.org/w/index.php?title=Module:Sandbox/Keyacom/color/TEST&diff=507694&oldid=507520

daniel claimed this task.

Seems resolved, per Adam.

This bug affected me on 1.38.2. It needs a backport.
My traceback:

[9c5499b47417c1c4c807be97] /index.php?title=Module:CGroup/UF&action=submit MediaWiki\Revision\IncompleteRevisionException: rev_page field must not be 0!

Backtrace:

from /www/wwwroot/podcast/includes/Revision/RevisionStore.php(415)
#0 /www/wwwroot/podcast/includes/Revision/RevisionStore.php(476): MediaWiki\Revision\RevisionStore->failOnEmpty()
#1 /www/wwwroot/podcast/includes/Storage/PageUpdater.php(1330): MediaWiki\Revision\RevisionStore->insertRevisionOn()
#2 /www/wwwroot/podcast/includes/Storage/PageUpdater.php(909): MediaWiki\Storage\PageUpdater->doModify()
#3 /www/wwwroot/podcast/includes/EditPage.php(2368): MediaWiki\Storage\PageUpdater->saveRevision()
#4 /www/wwwroot/podcast/includes/EditPage.php(1694): EditPage->internalAttemptSave()
#5 /www/wwwroot/podcast/includes/EditPage.php(671): EditPage->attemptSave()
#6 /www/wwwroot/podcast/includes/actions/EditAction.php(71): EditPage->edit()
#7 /www/wwwroot/podcast/includes/actions/SubmitAction.php(38): EditAction->show()
#8 /www/wwwroot/podcast/includes/MediaWiki.php(543): SubmitAction->show()
#9 /www/wwwroot/podcast/includes/MediaWiki.php(321): MediaWiki->performAction()
#10 /www/wwwroot/podcast/includes/MediaWiki.php(912): MediaWiki->performRequest()
#11 /www/wwwroot/podcast/includes/MediaWiki.php(563): MediaWiki->main()
#12 /www/wwwroot/podcast/index.php(53): MediaWiki->run()
#13 /www/wwwroot/podcast/index.php(46): wfIndexMain()
#14 {main}

And I happens to edit an module in subpages, with blank summary, and with TemplateSandbox on as well.

Applying the patch will fix the issue in 1.38.2 as well.

Change 814317 had a related patch set uploaded (by Zabe; author: Daniel Kinzler):

[mediawiki/core@REL1_38] Use page ID from parent revision, improve logging.

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

Change 814317 merged by jenkins-bot:

[mediawiki/core@REL1_38] Use page ID from parent revision, improve logging.

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