Topic on Project:Support desk

Updating to 1.29 can only be done in non-readonly mode (revised for 1.31.0)

6
Summary by PlavorSeol

Done

TheMatt (talkcontribs)

All, this is an odd one. I updated my 1.28.2 install to 1.29 today and at the end I do my usual 'php maintenance/update.php'. But on doing that, things failed. If I tried to load a wikipage I got:

[WXihOq3smIUAAEBThTYAAAAb] 2017-07-26 14:03:39: Fatal exception of type "Wikimedia\Rdbms\DBQueryError".

Huh. So, looking around I followed:

Set $wgShowDBErrorBacktrace = true; at the bottom of LocalSettings.php to show detailed debugging information

and then re-ran the update.php and:

...wl_notificationtimestamp is already nullable.

...index times already set on logging table.

...have ipb_range_start field in ipblocks table.

[37fe685e9f4eecdeed47e3a4] [no req]   Wikimedia\Rdbms\DBReadOnlyError from line 858 of /home/site/site.org/wiki/includes/libs/rdbms/database/Database.php: Database is read-only: Maintenance is underway. Website is on read-only mode

Backtrace:

#0 /home/site/site.org/wiki/includes/installer/MysqlUpdater.php(833): Wikimedia\Rdbms\Database->query(string, string)

#1 [internal function]: MysqlUpdater->doPageRandomUpdate()

#2 /home/site/site.org/wiki/includes/installer/DatabaseUpdater.php(472): call_user_func_array(array, array)

#3 /home/site/site.org/wiki/includes/installer/DatabaseUpdater.php(436): DatabaseUpdater->runUpdates(array, boolean)

#4 /home/site/site.org/wiki/maintenance/update.php(174): DatabaseUpdater->doUpdates(array)

#5 /home/site/site.org/wiki/maintenance/doMaintenance.php(111): UpdateMediaWiki->execute()

#6 /home/site/site.org/wiki/maintenance/update.php(219): require_once(string)

#7 {main}

(urls mangled for safety's sake)

So, I then edited my LocalSettings.php to turn off readonly and, bang, it worked. But I'm sure in the past I'd not needed to and even this page:

Manual:Upgrading#Can my wiki stay online while it is upgrading.3F

seems to say I can do the update in readonly mode.

Any idea what I did wrong? FYI my PHP is 5.6.29 and my MySQL is 5.6.34-log

Ciencia Al Poder (talkcontribs)

Reported in task T151833. Apparently update.php is honoring $wgReadOnly since MediaWiki 1.27... You'll have to unset $wgReadOnly, and if you want nobody to be able to edit while upgrading, you may want to fiddle with Manual:User rights revoking edit, move, upload, deletion rights for everyone during the upgrade...

Lady G2016 (talkcontribs)

I'm reopening this topic, as it applies to my upgrade from 1.27.4 to 1.31.0. @Ciencia Al Poder provided the solution I was looking for.

I also ran my usual 'php maintenance/update.php' and encountered the same exception when I attempted to view my wiki in the web browser.

[W48fI-QM63YPxj1AGEiUeQAAAA8] 2018-09-05 00:11:15: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

My command line and results:

$ php update.php

MediaWiki 1.31.0 Updater
Your composer.lock file is up to date with current dependencies!
Going to run database updates for wiki
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
...indexes seem up to 20031107 standards.

...

...wl_notificationtimestamp is already nullable.
...index times already set on logging table.
...have ipb_range_start field in ipblocks table.
Set $wgShowExceptionDetails = true; and $wgShowDBErrorBacktrace = true; at the bottom of LocalSettings.php to show detailed debugging information.

The important point is that the error message did not display. Only the 2nd line explaining how to set the error reporting appears. The MariaDB error log contained this error:

1180903 10:44:25 [ERROR] Incorrect definition of table mysql.proc: expected column 'sql_mode' at position 14 to have type set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVA

Without an error message, I was very concerned my database was broken. I then implemented the error reporting variables in LocalSettings.php. The error message is displayed:

...wl_notificationtimestamp is already nullable.
...index times already set on logging table.
...have ipb_range_start field in ipblocks table.
[75cb065940c7af8c0bae4737] [no req]   Wikimedia\Rdbms\DBReadOnlyError from line 1121 of /var/www/html/w/includes/libs/rdbms/database/Database.php: Database is read-only: Software upgrade
Backtrace:

#0 /var/www/html/w/includes/installer/MysqlUpdater.php(878): Wikimedia\Rdbms\Database->query(string, string)
#1 /var/www/html/w/includes/installer/DatabaseUpdater.php(482): MysqlUpdater->doPageRandomUpdate()
#2 /var/www/html/w/includes/installer/DatabaseUpdater.php(446): DatabaseUpdater->runUpdates(array, boolean)
#3 /var/www/html/w/maintenance/update.php(200): DatabaseUpdater->doUpdates(array)
#4 /var/www/html/w/maintenance/doMaintenance.php(94): UpdateMediaWiki->execute()
#5 /var/www/html/w/maintenance/update.php(245): require_once(string)
#6 {main}

I then set unset $wgreadonly and the upgrade proceeded with no error.

Not displaying the error message is a bug. Should it be reported as a new bug, or add this report to Bug T151833?

Bug T151833 also provides a good solution to have the wiki set to read-only for users, but unset for command line updates.

I recommend this implementation for the user manual: Can my wiki stay online while it is upgrading?

  • Alternatively, you can also place the wiki in read-only mode for users, but keep the wiki writable for the upgrade script.
$wgReadOnly = ( PHP_SAPI === 'cli' ) ? false : 'This wiki is currently being upgraded to a newer software version.'; 

A side effect of setting $wgReadOnly during the upgrade is that I am prevented from logging in to my wiki. I am using https:// protocol. This error message is displayed:

There seems to be a problem with your login session; this action has been canceled as a precaution against session hijacking. Please resubmit the form.

Perhaps Manual:$wgReadOnly should be updated?

Ciencia Al Poder (talkcontribs)
Lady G2016 (talkcontribs)

My production wiki has been successfully updated. I have created Bug T203914 to report the missing error message.

Suggestion: Please link the revised $wgReadOnly configuration to the upgrade page.

I recommend changing the text from:

  1. Place the database in read-only mode by inserting the following variable into LocalSettings.php in the old directory - users will see this message if they attempt an edit during the upgrade process:
    $wgReadOnlyManual:$wgReadOnly = 'Upgrading to MediaWiki 1.31.0';
    • This no longer works since MediaWiki 1.27, which also prevents running the update script. See task T151833.

To:

  1. Place the database in read-only mode by inserting the following variable into LocalSettings.php in the old directory - users will see this message if they attempt an edit during the upgrade process:
    $wgReadOnlyManual:$wgReadOnly = 'Upgrading to MediaWiki 1.31.0';
Ciencia Al Poder (talkcontribs)

Done.