Page MenuHomePhabricator

Undelete: "LogicException: Missing page state before update"
Closed, ResolvedPublicPRODUCTION ERROR

Description

Trying to undelete https://en.wikipedia.org/wiki/Special:Undelete/City_University_of_Mogadishu

[fef0e3f8-de07-4926-b904-acfd22faa0eb] 2025-04-12 05:29:49: Fatal exception of type "LogicException"
Error
normalized_message
[{reqId}] {exception_url}   LogicException: Missing page state before update
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.24/includes/Storage/DerivedPageDataUpdater.php(1716)
#0/srv/mediawiki/php-1.44.0-wmf.24/includes/Storage/DerivedPageDataUpdater.php(1664)MediaWiki\Storage\DerivedPageDataUpdater->getPageRevisionUpdatedEvent()
#1/srv/mediawiki/php-1.44.0-wmf.24/includes/Storage/DerivedPageDataUpdater.php(1551)MediaWiki\Storage\DerivedPageDataUpdater->emitEvents()
#2/srv/mediawiki/php-1.44.0-wmf.24/includes/page/UndeletePage.php(652)MediaWiki\Storage\DerivedPageDataUpdater->doUpdates()
#3/srv/mediawiki/php-1.44.0-wmf.24/includes/page/UndeletePage.php(297)MediaWiki\Page\UndeletePage->undeleteRevisions(MediaWiki\Page\PageIdentityValue, array, string, bool)
Impact

Seen 12 times over the last 7 days: https://logstash.wikimedia.org/goto/374bbd5ed74ba1027413fc23325ced91

Notes

The bug seemes to triggered sometimes when trying to restore a revision into an existing page, when the restored revision is newer than the current latest revision. This was the case for City_University_of_Mogadishu. ewditing the page to create an evener newer revision allowed the old revision to be undeleted (and become the second-from-newest).

However, my attempt to reproduce the bug by re-creating htese conditions failed. I was able to restore both revisions successfully: https://www.mediawiki.org/wiki/Special:Log?type=delete&user=&page=User%3ADKinzler+%28WMF%29%2Ftest&wpdate=&tagfilter=&subtype=&wpFormIdentifier=logeventslist

Details

MediaWiki Version
1.44.0-wmf.24
Request URL
https://en.wikipedia.org/w/index.php?action=submit&title=*
Related Changes in Gerrit:

Event Timeline

Restricted Application changed the subtype of this task from "Task" to "Production Error". · View Herald TranscriptApr 12 2025, 5:30 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Aklapper renamed this task from LogicException on undelete to Undelete: "LogicException: Missing page state before update".Apr 12 2025, 9:11 PM
Aklapper set Request URL to https://en.wikipedia.org/w/index.php?action=submit&title=*.
Aklapper updated the task description. (Show Details)
Aklapper set Release Version to 1.44.0-wmf.24.

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

[mediawiki/core@master] undeletion: fix before-state in PageRevisionUpdatedEvent

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

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

[mediawiki/core@master] undeletion: fix before-state in PageRevisionUpdatedEvent

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

Note that this patch does not directly address the error as reported. The cause of the error is still unknown. It just fixes an inconsistency in related code, in the hope that it may avoid similar issues in the future. If we are lucky, it may end up fixing the error at hand as well.

I have not been able to preproduce the error locally. It would be useful to know whether it happens consistently for a given page, or if it just fails temporarily and later succeeds.

Actually... undeletion of https://en.wikipedia.org/wiki/City_University_of_Mogadishu failed on April 12, but the page was already undeleted on April 7th.

Was this a redundant undeletion attempt?

It happens consistently for the link in the task. https://en.wikipedia.org/wiki/Special:Undelete/City_University_of_Mogadishu

Thanks. I don't have sysop rights on enwiki, so I couldn't test. My suspicion is that this happens when trying to undelete a page that has already been undeleted. I'll work on reproducing it some more.

@Pppery Are there still archived revisions for this page?

Yes, there's one deleted edit, which is a redirect. And the current version isn't a redirect.

Yes, there's one deleted edit, which is a redirect. And the current version isn't a redirect.

Found it, thanks:

wikiadmin2023@10.64.32.13(enwiki)> select * from archive where ar_namespace = 0 and ar_title = "City_University_of_Mogadishu"\G
*************************** 1. row ***************************
        ar_id: 125386430
 ar_namespace: 0
     ar_title: City_University_of_Mogadishu
ar_comment_id: 502702150
     ar_actor: 196994261
 ar_timestamp: 20250325120203
ar_minor_edit: 1
    ar_rev_id: 1282270151
   ar_deleted: 0
       ar_len: 46
   ar_page_id: 59150008
 ar_parent_id: 1281929205
      ar_sha1: 8owcrlk025vks0s5q1drhuejrvnnovo
1 row in set (0.001 sec)

I see nothing special there... the fact that it's a redirect shouldn't matter...

The archived revision is newer than the newest revision on the page. So undeleting it would update the page content without creating the page. That's indeed the special case that I'm dealing with in the patch... though I couldn't trigger the error in my tests.

@Pppery Can you try making an edit to the page, so there is a newer version, and then undeleting the remaining revision? See if that works? It would just get injected into the history as the second-newest...

That worked.

Cool, thanks for checking! let's keep the ticket open anyway, until we are sure the cause is fixed. I'll summarize my findings later.

It's still not clear to me why and how this happens, but I have hopes for my patch to fix it. It's see what happens once it rides the train.

Change #1136416 merged by jenkins-bot:

[mediawiki/core@master] UndeletePage: fix before-state in PageRevisionUpdatedEvent

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

The error ewas last seen on April 17. Seems like it's fixed.