Page MenuHomePhabricator

MediaWiki update.php forgot to populate slot_roles
Open, MediumPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • upgrading a plain and simple MW from 1.29 (or 1.30 or 1.31.1 or else) to 1.36.1
  • try run update.php
  • after a while fail with: MediaWiki\Storage\NameTableAccessException from line 43 of /var/www/mediawiki-1.36.1/includes/Storage/NameTableAccessException.php: Failed to access name from slot_roles using name = main

Why happens?:
update.php have neglected to insert into slot_roles(role_name) values ("main");

What should have happened instead?:
Well it should have populated that table.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:
Upgrade MediaWiki from 1.29 (or later, up to probably the last LTS) to 1.36.1

Details

Event Timeline

BPirkle triaged this task as Medium priority.Jul 13 2021, 8:41 PM
BPirkle subscribed.

This sounds familiar, but maybe I'm thinking about T218223: Upgrade script from MW 1.29 to 1.32 seems to break revision table, which at a glance seems to be a different thing.

Change 765247 had a related patch set uploaded (by Seb35; author: Seb35):

[mediawiki/core@master] schema: insert \"main\" slot_role when upgrading

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

Believe me or not but I've found a simple workaround in how you call the command.

First, my problem:

$ php7.4 w/maintenance/update.php
MediaWiki 1.38.7 Updater

Your composer.lock file is up to date with current dependencies!
Going to run database updates for normeiccu
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ...0
...collations up-to-date.
...have el_index_60 field in externallinks table.
...ug_user_group key doesn't exist.
...have ug_expiry field in user_groups table.
...index img_user_timestamp already set on image table.
Modifying img_media_type field of table image...done.
Creating ip_changes table...done.
Renaming index cl_from into PRIMARY to table categorylinks...done.
Renaming index tl_from into PRIMARY to table templatelinks...done.
Renaming index pl_from into PRIMARY to table pagelinks...done.
...index PRIMARY already set on text table.
Renaming index il_from into PRIMARY to table imagelinks...done.
Renaming index iwl_from into PRIMARY to table iwlinks...done.
Renaming index ll_from into PRIMARY to table langlinks...done.
Renaming index ls_field_val into PRIMARY to table log_search...done.
Renaming index md_module_skin into PRIMARY to table module_deps...done.
...index PRIMARY already set on objectcache table.
Renaming index qci_type into PRIMARY to table querycache_info...done.
Renaming index ss_row_id into PRIMARY to table site_stats...done.
Renaming index ufg_user_group into PRIMARY to table user_former_groups...done.
Renaming index user_properties_user_property into PRIMARY to table user_properties...done.
Creating comment table...done.
Creating revision_comment_temp table...done.
Adding ar_comment_id field to table archive...done.
Adding fa_description_id field to table filearchive...done.
Modifying img_description field of table image...done.
Adding ipb_reason_id field to table ipblocks...done.
Adding log_comment_id field to table logging...done.
Adding oi_description_id field to table oldimage...done.
Adding pt_reason_id field to table protected_titles...done.
Adding rc_comment_id field to table recentchanges...done.
Adding img_description_id field to table image...done.
Migrating comments to the 'comments' table, printing progress markers. For large
databases, you may want to hit Ctrl-C and do this manually with
maintenance/migrateComments.php.
Beginning migration of revision.rev_comment to revision_comment_temp.revcomment_comment_id
... 737
... 1382
<omissis lines>
Completed migration, updated 13958 row(s) with 3158 new comment(s)
Beginning migration of archive.ar_comment to archive.ar_comment_id
... 151
... 307
<omissis lines>
Completed migration, updated 3919 row(s) with 621 new comment(s)
Beginning migration of ipblocks.ipb_reason to ipblocks.ipb_reason_id
Completed migration, updated 0 row(s) with 0 new comment(s)
Beginning migration of image.img_description to image.img_description_id
<omissis lines>
Completed migration, updated 2213 row(s) with 12 new comment(s)
Beginning migration of oldimage.oi_description to oldimage.oi_description_id
<omissis lines>
Completed migration, updated 94 row(s) with 0 new comment(s)
Beginning migration of filearchive.fa_deleted_reason to filearchive.fa_deleted_reason_id
... 129
... 241
Completed migration, updated 188 row(s) with 2 new comment(s)
Beginning migration of filearchive.fa_description to filearchive.fa_description_id
... 129
... 241
Completed migration, updated 188 row(s) with 7 new comment(s)
Beginning migration of recentchanges.rc_comment to recentchanges.rc_comment_id
... 19573
... 19673
... 19694
Completed migration, updated 221 row(s) with 0 new comment(s)
Beginning migration of logging.log_comment to logging.log_comment_id
... 100
... 200
<omissis lines>
Completed migration, updated 16239 row(s) with 354 new comment(s)
Beginning migration of protected_titles.pt_reason to protected_titles.pt_reason_id
Completed migration, updated 0 row(s) with 0 new comment(s)
done.
Renaming index lc_lang_key into PRIMARY to table l10n_cache...done.
Making bot_passwords.bp_user into an unsigned int...done.
Making change_tag.ct_log_id into an unsigned int...done.
Making change_tag.ct_rev_id into an unsigned int...done.
...user_newtalk.user_id is already unsigned int.
Making user_properties.up_user into an unsigned int...done.
Making change_tag.ct_rc_id into an unsigned int...done.
Creating slots table...done.
...have slot_origin field in slots table.
Creating content table...done.
Creating slot_roles table...done.
Creating content_models table...done.
Migrating archive ar_text to modern storage.
Migrating ar_text to modern storage...
Completed ar_text migration, 0 rows updated, 0 missing data.
Dropping ar_text and ar_flags columns...done.
Creating actor table...done.
Creating revision_actor_temp table...done.
Adding ar_actor field to table archive...done.
Adding ipb_by_actor field to table ipblocks...done.
Adding img_actor field to table image...done.
Adding oi_actor field to table oldimage...done.
Adding fa_actor field to table filearchive...done.
Adding rc_actor field to table recentchanges...done.
Adding log_actor field to table logging...done.
Migrating actors to the 'actor' table, printing progress markers. For large
databases, you may want to hit Ctrl-C and do this manually with
maintenance/migrateActors.php.
Creating actor entries for all registered users
... 1 - 33
Completed actor creation, added 33 new actor(s)
Beginning migration of revision.rev_user and revision.rev_user_text to revision_actor_temp.revactor_actor
... rev_id=737
... rev_id=1382
<omissis lines>
Completed migration, updated 13958 row(s) with 0 new actor(s), 0 error(s)
Beginning migration of archive.ar_user and archive.ar_user_text to archive.ar_actor
MediaWiki\Storage\NameTableAccessException from line 43 of /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/Storage/NameTableAccessException.php: Failed to access name from slot_roles using name = main
#0 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/Storage/NameTableStore.php(262): MediaWiki\Storage\NameTableAccessException::newFromDetails()
#1 [internal function]: MediaWiki\Storage\NameTableStore->getId()
#2 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/Revision/RevisionStore.php(2170): array_map()
#3 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/Revision/RevisionStore.php(2057): MediaWiki\Revision\RevisionStore->getSlotRowsForBatch()
#4 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/cache/MessageCache.php(572): MediaWiki\Revision\RevisionStore->newRevisionsFromBatch()
#5 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/cache/MessageCache.php(447): MessageCache->loadFromDB()
#6 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/cache/MessageCache.php(370): MessageCache->loadFromDBWithLock()
#7 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/cache/MessageCache.php(1112): MessageCache->load()
#8 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/cache/MessageCache.php(1040): MessageCache->getMsgFromNamespace()
#9 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/cache/MessageCache.php(1011): MessageCache->getMessageForLang()
#10 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/cache/MessageCache.php(953): MessageCache->getMessageFromFallbackChain()
#11 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/language/Message.php(1491): MessageCache->get()
#12 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/language/Message.php(968): Message->fetchMessage()
#13 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/language/Message.php(957): Message->format()
#14 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/Message/TextFormatter.php(51): Message->toString()
#15 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/user/UserNameUtils.php(193): MediaWiki\Message\TextFormatter->format()
#16 /var/www/iccu/httpdocs/mediawiki-1.38.7/maintenance/includes/MigrateActors.php(194): MediaWiki\User\UserNameUtils->isUsable()
#17 /var/www/iccu/httpdocs/mediawiki-1.38.7/maintenance/includes/MigrateActors.php(305): MigrateActors->addActorsForRows()
#18 /var/www/iccu/httpdocs/mediawiki-1.38.7/maintenance/includes/MigrateActors.php(107): MigrateActors->migrate()
#19 /var/www/iccu/httpdocs/mediawiki-1.38.7/maintenance/includes/LoggedUpdateMaintenance.php(45): MigrateActors->doDBUpdates()
#20 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/installer/DatabaseUpdater.php(1276): LoggedUpdateMaintenance->execute()
#21 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/installer/DatabaseUpdater.php(533): DatabaseUpdater->migrateActors()
#22 /var/www/iccu/httpdocs/mediawiki-1.38.7/includes/installer/DatabaseUpdater.php(497): DatabaseUpdater->runUpdates()
#23 /var/www/iccu/httpdocs/mediawiki-1.38.7/maintenance/update.php(193): DatabaseUpdater->doUpdates()
#24 /var/www/iccu/httpdocs/mediawiki-1.38.7/maintenance/doMaintenance.php(114): UpdateMediaWiki->execute()
#25 /var/www/iccu/httpdocs/mediawiki-1.38.7/maintenance/update.php(264): require_once('/var/www/iccu/h...')

Note the error:

NameTableAccessException.php: Failed to access name from slot_roles using name = main

Solution

Correct call:

cd w
php7.4 maintenance/update.php

Note that I manually entered the MediaWiki installation path directory (w).

I'm quite sure about this fact since I've restored the backup from one attempt to the other one, and just trying in this way solved for me (explosion mind meme).

It's weird since the script worked for minutes and then with an SQL crash.

In short

  1. restore database backup
  2. call maintenance script again from the MediaWiki directory (cd w)

Well. I can sleep now. After 5 hours of nonsense troubleshooting and execution of completely unrelated maintenance scripts. Just changing directory was sufficient. Hope it helps.

I'm somewhat confused how that would make any actual difference...

If there was some path issue (file not found), there would've surely been output of that...

Reedy renamed this task from Mediawiki upgrade.php forgot to populate slot_roles to MediaWiki update.php forgot to populate slot_roles.Thu, Mar 26, 8:43 PM
Reedy updated the task description. (Show Details)

Change #765247 abandoned by Hashar:

[mediawiki/core@master] schema: insert "main" slot_role when upgrading

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

Change #765247 restored by Thcipriani:

[mediawiki/core@master] schema: insert "main" slot_role when upgrading

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