Page MenuHomePhabricator

maintenance/update.php complains about locked database when $wgReadOnly is set
Open, Needs TriagePublic


I'm in the process of updating from 1.25 to 1.28, and I find it good measure to set $wgReadOnly before starting the upgrade in order to have consistent backups and exclusive access to the database while maintenance/upgrade.php runs. The Upgrade Manual also advises to do so. And the documentation for $wgReadOnly contains a big red warning that maintenance scripts may ignore this setting :-)

However, the database updater for 1.28 complains in that case, in my opinion unneccessarily:

# php maintenance/update.php
MediaWiki 1.28.0 Updater

Your composer.lock file is up to date with current dependencies!
Going to run database updates for mediawiki_stratum0-mw_
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
Turning off Content Handler DB fields for this part of upgrade.
...have ipb_id field in ipblocks table.
...have ipb_expiry field in ipblocks table.
...already have interwiki table
...wl_notificationtimestamp is already nullable.
...index times already set on logging table.
...have ipb_range_start field in ipblocks table.
[d78ec32197315f3715770f28] [no req]   DBReadOnlyError from line 837 of /srv/www/mediawiki-1.28.0/includes/libs/rdbms/database/Database.php: Database is read-only: This wiki is currently being upgraded to a newer software version.
#0 /srv/www/mediawiki-1.28.0/includes/installer/MysqlUpdater.php(823): Database->query(string, string)
#1 [internal function]: MysqlUpdater->doPageRandomUpdate()
#2 /srv/www/mediawiki-1.28.0/includes/installer/DatabaseUpdater.php(472): call_user_func_array(array, array)
#3 /srv/www/mediawiki-1.28.0/includes/installer/DatabaseUpdater.php(433): DatabaseUpdater->runUpdates(array, boolean)
#4 /srv/www/mediawiki-1.28.0/maintenance/update.php(172): DatabaseUpdater->doUpdates(array)
#5 /srv/www/mediawiki-1.28.0/maintenance/doMaintenance.php(111): UpdateMediaWiki->execute()
#6 /srv/www/mediawiki-1.28.0/maintenance/update.php(217): require_once(string)
#7 {main}

Previous updaters ignored the read-only setting, justifiably. I also cannot find anything in the recent Release Notes that this change was made on purpose.

Event Timeline

I've tested this and is still current as of MediaWiki 1.29. This started happening since MediaWiki 1.27.

Have you tied something like this?

$wgReadOnly = ( PHP_SAPI === 'cli' ) ? false : 'This wiki is currently being upgraded to a newer software version.'

$wgReadOnly is enforced at the LB/DB layer in addition to random callers checked wfReadOnly().

Hmmm, may be a good compromise. It will require only to update documentation