Jump to content

Topic on Project:Support desk

Upgrade from 1.27.4 to 1.31.0 fails during database update

6
Summary last edited by Ciencia Al Poder 08:38, 16 July 2018 6 years ago

A database permissions problem reported by the database schema update script (/maintenance update.php) was misleading.

The problem was tracked to an incompatible LocalSettings.php file.

Old installations were setting $wgDBmwschema to 'mediawiki' in LocalSettings.php. This setting was ignored for MySQL installs, but it's now being taken into account since MediaWiki 1.31. Remove this setting from LocalSettings.php if you're using MySQL.

Lady G2016 (talkcontribs)

Current: MediaWiki 1.27.4 Upgrade to: MediaWiki 1.31.0

PHP 7.1.17 (fpm-fcgi) MariaDB 10.2.14 URL - localhost (test environment)

Running the maintenance script update.php produces a privilege error:

=

Turning off Content Handler DB fields for this part of upgrade. Adding ipb_id field to table ipblocks ...[06a6bcb5ba7a28f0640c1c8d] [no req] Wikimedia\Rdbms\DBQueryError from line 1457 of /var/www/html/w/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? Query: ALTER TABLE `mediawiki`.`ipblocks`

ADD ipb_auto tinyint NOT NULL default '0',
ADD ipb_id int NOT NULL auto_increment,
ADD PRIMARY KEY (ipb_id)

Function: Wikimedia\Rdbms\Database::sourceFile( /var/www/html/w/maintenance/archives/patch-ipblocks.sql ) Error: 1142 ALTER command denied to user 'wiki'@'localhost' for table 'ipblocks' (localhost)

Backtrace:

  1. 0 /var/www/html/w/includes/libs/rdbms/database/Database.php(1427): Wikimedia\Rdbms\Database->makeQueryException(string, integer, string, string)
  2. 1 /var/www/html/w/includes/libs/rdbms/database/Database.php(1200): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
  3. 2 /var/www/html/w/includes/libs/rdbms/database/Database.php(4194): Wikimedia\Rdbms\Database->query(string, string)
  4. 3 /var/www/html/w/includes/libs/rdbms/database/Database.php(4129): Wikimedia\Rdbms\Database->sourceStream(resource (closed), NULL, NULL, string, NULL)
  5. 4 /var/www/html/w/includes/installer/DatabaseUpdater.php(683): Wikimedia\Rdbms\Database->sourceFile(string)
  6. 5 /var/www/html/w/includes/installer/DatabaseUpdater.php(751): DatabaseUpdater->applyPatch(string, boolean, string)
  7. 6 /var/www/html/w/includes/installer/DatabaseUpdater.php(482): DatabaseUpdater->addField(string, string, string)
  8. 7 /var/www/html/w/includes/installer/DatabaseUpdater.php(446): DatabaseUpdater->runUpdates(array, boolean)
  9. 8 /var/www/html/w/maintenance/update.php(200): DatabaseUpdater->doUpdates(array)
  10. 9 /var/www/html/w/maintenance/doMaintenance.php(94): UpdateMediaWiki->execute()
  11. 10 /var/www/html/w/maintenance/update.php(245): require_once(string)
  12. 11 {main}
==

Running the update script as a database user with administrator privileges produces this error:

Function: Wikimedia\Rdbms\Database::sourceFile( /var/www/html/w/maintenance/archives/patch-ipblocks.sql ) Error: 1146 Table 'mediawiki.ipblocks' doesn't exist (localhost)

(same backtrace)

==

My database user account has "GRANT ALL PRIVILEGES ON `wiki`.* TO 'wiki'@'localhost'".

There are no errors when I run the update script from a version 1.31 clean install.

There are no errors when I run the update script from my current version 1.27.4.

I am blocked upgrading to version 1.31.0.

How can I debug this problem? I do not see any mention of this problem in Phabricator.

2001:16B8:106B:1200:B5FB:6E29:5A6F:ED48 (talkcontribs)

This is a problem with MySQL/MariaDB permissions. You are speaking about two different databases!

> ALTER TABLE `mediawiki`.`ipblocks`

> ALTER command denied to user 'wiki'@'localhost' for table 'ipblocks'

> GRANT ALL PRIVILEGES ON `wiki`.* TO 'wiki'@'localhost'

The correct database name obviously is "mediawiki", not "wiki".

Lady G2016 (talkcontribs)

Thank you for the reply. I agree, the database name does not match. There is no mention of 'mediawiki' in my LocalSettings.php file; the correct database name is 'wiki'. Therefore, the database name has changed during the script execution.

I was incorrect in my earlier statement of There are no errors when I run the update script from a version 1.31 clean install. The script did indeed run, but that was for a clean (new) database. The conditions which triggered my error did not occur - modification of an existing database.

All maintenance scripts utilize the configurations in LocalSettings.php. Perhaps this is the source of my problem? I replaced my existing LocalSettings.php file with the version created from a clean install. It worked!

I then modified the "clean" LocalSettings.php to align with my existing configuration. Extensions were added to the bottom of the file. (Previously, they were near the top of the file.) I don't know if the extension placement or a configuration setting was source of my problem.

In any case, I have a working configuration and can proceed with my testing.

Albert Ke (talkcontribs)

I had exactly the same error message as @Lady_G2016 indicated when upgrading from MW1.30 to MW1.31. So I asked for help from my University of Colorado colleague at the IT department, Karen. Karen indicated the following:

It almost looks like there is a code error. In most cases, the settings use $wgDBname, which properly points to the mysql database "csdms_wiki" [the dbname of my wiki].   However, in Setup.php, there is a reference to $wgDBmwschema, which, per LocalSettings.php should only be used if you are using postgresql. In LocalSettings.php, $wgDBmwschema points to 'mediawiki'. So maybe try changing the value for $wgDBmwschema in LocalSettings.php from 'mediawiki' to 'csdms_wiki'?

I did that and the update.php script runs smoothly. So could it be that the reference in the Setup.php to $wgDBmwschema shouldn't be there when running the wiki from a mysql database?

Thanks,

Albert.

Lziobro (talkcontribs)

I had this exact issue as well. I use MySQL. My LocalSettings.php, which was originally generated quite a many versions ago, had this code:

$wgDBmwschema       = 'mediawiki';

I changed it to this, and the problem went away.

$wgDBmwschema       = $wgDBname;
Ciencia Al Poder (talkcontribs)