Page MenuHomePhabricator

Upgrade to 1.31 results in pages no longer being editable with "The revision #0 of the page named "Instruments, surgical" does not exist. " error
Open, HighPublicBUG REPORT

Description

Steps to Reproduce:
https://wiki.travellerrpg.com/index.php?title=Instruments,_surgical&action=edit

I have looked through all the existing documentation around this issue, including many of the issues here, on stack overflow, and other places. I an unable to find any database corruption from these sources. All of the SHA1 fields in the revisions and content tables are populated. All of the links between the page, revision, slots, and content pages are correct (to my ability to query the database)

Relevant History:
The wiki was founded in Wikia in 2006. In 2013 the decision was to move out of Wikia. We got wikipedia export. Because Wikia was set up with a shared user database, the export had no user information in it. So when we imported the database into our new, local Mediawiki, all of the user information was not included. The import was brought into mediawiki version 1.21. We rebuilt the users by having them sign up again.

Late last year we upgrade from 1.24 to 1.31. The upgrade went perfectly to the best of our knowledge. There were no errors in the upgrade process. But we began to find a few of these pages with no data on them, they would display this "revision does not exist" error.

I've gone through the various fix scripts for this issue, but can't find any data corruption.

In digging further, I found that there are several entries in the revisions table where the rev_user_text is set but the rev_user is not (it has a value of 0). These are users who were active while we were in Wikia, but never showed back up in our new location, or we never fixed the entries. The revisions table has a name but no ID and there is no corresponding entry in the users table (or supporting tables).

This didn't cause problems in earlier versions of the database. So I selected one of these missing users "Marm6902". and chased this down further.

select page_id,  page_namespace, page_title from mw_page, mw_revision where page_latest = rev_id and rev_user_text = 'Marm6902'

page_id	page_namespace	page_title 	
8841 	0	Instruments,_surgical 
9662 	1	Autopop
10581 	0	Autoserver 
10584 	1	Foldsword
10852 	1	Siliwishisee
10863 	0	Auto-Angel  
10865 	14	Food_and_Drink
10868 	1	Everfresh_Sandwiches
10884 	14	Martial_arts
10934 	1	GC96/B

Every one of these pages has this problem. The query find the pages which the active revision were edited by one of these missing users.

What broke? and how do I fix the underlying database to allow viewing / editing of these articles.

Event Timeline

Hi @Tjoneslow, thanks for taking the time to report this!
I wonder if T112384#5545007 and T111605#3800257 might be related here?

Thank you for posting the notes above. I looked through the reports.

One recommended running the mainenance/cleanupUsersWithNoId.php script. So I ran the script as follows:

php maintenance/cleanupUsersWithNoId.php --assign -p wikia

This updated the users in the revisions table to add the "wikia>" prefix to the names. But this didn't fix the underlying problem:

I turned the debugging on and got this error message:

<b>Notice</b>: Page Autoserver exists but has no (visible) revisions! [Called from WikiPage::{closure} in /var/www/html/wiki/includes/page/WikiPage.php at line 662] in <b>/var/www/html/wiki/includes/debug/MWDebug.php</b> on line <b>309</b><br />

And the debug log has the following information:

[DBQuery] wikitrav_mw854-mw_ SELECT /* MediaWiki\Revision\RevisionStore::fetchRevisionRowFromConds  */  rev_id,rev_page,rev_timestamp,rev_minor_edit,rev_deleted,rev_len,rev_parent_id,rev_sha1,comment_rev_comment.comment_text AS `rev_comment_text`,comment_rev_comment.comment_data AS `rev_comment_data`,comment_rev_comment.comment_id AS `rev_comment_cid`,actor_rev_user.actor_user AS `rev_user`,actor_rev_user.actor_name AS `rev_user_text`,temp_rev_user.revactor_actor AS `rev_actor`,page_namespace,page_title,page_id,page_latest,page_is_redirect,page_len,user_name  FROM `mw_revision` JOIN `mw_revision_comment_temp` `temp_rev_comment` ON ((temp_rev_comment.revcomment_rev = rev_id)) JOIN `mw_comment` `comment_rev_comment` ON ((comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id)) JOIN `mw_revision_actor_temp` `temp_rev_user` ON ((temp_rev_user.revactor_rev = rev_id)) JOIN `mw_actor` `actor_rev_user` ON ((actor_rev_user.actor_id = temp_rev_user.revactor_actor)) JOIN `mw_page` ON ((page_id = rev_page)) LEFT JOIN `mw_user` ON ((actor_rev_user.actor_user != 0) AND (user_id = actor_rev_user.actor_user))   WHERE rev_id = '37421'  LIMIT 1
[error] [f9a473a3d78e8682fc281ab5] /Auto-Angel   ErrorException from line 309 of /var/www/html/wiki/includes/debug/MWDebug.php: PHP Notice: Page Auto-Angel exists but has no (visible) revisions! [Called from WikiPage::{closure} in /var/www/html/wiki/includes/page/WikiPage.php at line 662]
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /var/www/html/wiki/includes/debug/MWDebug.php(309): trigger_error(string, integer)
#2 /var/www/html/wiki/includes/debug/MWDebug.php(164): MWDebug::sendMessage(string, array, string, integer)
#3 /var/www/html/wiki/includes/GlobalFunctions.php(1093): MWDebug::warning(string, integer, integer, string)
#4 /var/www/html/wiki/includes/page/WikiPage.php(662): wfWarn(string)
#5 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1414): WikiPage->{closure}(boolean, integer, array, NULL)
#6 /var/www/html/wiki/includes/libs/objectcache/WANObjectCache.php(1275): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#7 /var/www/html/wiki/includes/page/WikiPage.php(665): WANObjectCache->getWithSetCallback(string, integer, Closure)
#8 /var/www/html/wiki/includes/page/WikiPage.php(287): WikiPage->getContentModel()
#9 /var/www/html/wiki/includes/page/WikiPage.php(274): WikiPage->getContentHandler()
#10 /var/www/html/wiki/includes/actions/Action.php(98): WikiPage->getActionOverrides()
#11 /var/www/html/wiki/includes/actions/Action.php(155): Action::factory(string, WikiPage, RequestContext)
#12 /var/www/html/wiki/includes/MediaWiki.php(155): Action::getActionName(RequestContext)
#13 /var/www/html/wiki/includes/MediaWiki.php(782): MediaWiki->getAction()
#14 /var/www/html/wiki/includes/MediaWiki.php(515): MediaWiki->main()
#15 /var/www/html/wiki/index.php(42): MediaWiki->run()
#16 {main}

I'm going to pull apart the failing query to see if I can figure out what's missing from the database.

Doing more work with a local copy of the database I found the actor table doesn't have the "extenal" users because they were not in the user table to copy into the actor table, and the supporting tables.

To fix this problem I ran the following steps.

  1. Run php maintenance/cleanupUsersWithNoId.php --assign -p wikia. This makes the revision.rev_user_text easier to find and manipualate. And makes it more obvious that these are no longer active users.
  1. select count(distinct rev_user_text) from mw_revision where rev_user_text like 'wikia>%''; This query gives the number of users we haven't updated from the revision table. My count is 220. I can do this in one query. For more you may want to batch them.
  1. `insert into mw_actor (actor_user, actor_name)

select distinct 0, rev_user_text from mw_revision where rev_user_text like 'wikia>%'; This query creates the 220 rows in the actor` table from the names in the revision table.

  1. insert into mw_revision_actor_temp (revactor_rev, revactor_actor, revactor_timestamp, revactor_page) select rev_id actor_id, rev_timestamp, rev_page from mw_revision, mw_actor where rev_user_text = actor_name and rev_user_text like 'wikia>%'; This query updates the revision_actor_temp table to link the revision to the actor. Again, I do this in one blast because my database only has 21K entries that need to be updated. But this may need to be batched for larger databases.

Once these are completed and committed the pages are once again visible and the page history is complete. The user names are linked to wikia, which is good enough for my use.

Now to apply this to my production instance.

I see the same problem https://wiki.physikerwelt.de/index.php?&oldid=497 exists but if I click on next version I am seeing https://wiki.physikerwelt.de/index.php?title=Weihnachts%C3%BCbung_zur_Allgemeinen_Relativit%C3%A4tstheorie_II. If I click edit there I see the text of ticket title in German. I have not tried the fix proposed in https://phabricator.wikimedia.org/T249185#6028521