Page MenuHomePhabricator

Error: 1050 Table 'xxx' already exists (localhost:3306) problem with MW1.28 update.php when $wgSharedDB used.
Open, Needs TriagePublic


Currently I only know that this problem exist in my wiki, not sure whether will others experience same problem during their upgrade or not.

I have $wgSharedDB = 'wikidata'; in localsettings and the database user used for upgrade have full Permissions for database "mainwiki" & "wikidata".

I tried to upgrade the wikidatabase by:
php /wiki/maintenance/update.php --dbuser root --dbpass ****** --conf /wiki/LocalSettings.php --doshared --wiki mainwiki

and it return following error message:

Creating interwiki table ...[1d159d68c65e6cbd8a3b399a] [no req] DBQueryError from line 1054 of /wiki/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: CREATE TABLE wikidata.interwiki (
iw_prefix varchar(32) NOT NULL,
iw_url blob NOT NULL,
iw_local BOOL NOT NULL,
UNIQUE KEY iw_prefix (iw_prefix)
Function: Database::sourceFile( /wiki/maintenance/archives/patch-interwiki.sql )
Error: 1050 Table 'interwiki' already exists (localhost:3306)
#0 /wiki/includes/libs/rdbms/database/Database.php(912): Database->reportQueryError(string, integer, string, string, boolean)
#1 /wiki/includes/libs/rdbms/database/Database.php(3136): Database->query(string, string)
#2 /wiki/includes/libs/rdbms/database/Database.php(3084): Database->sourceStream(unknown type, NULL, NULL, string, NULL)
#3 /wiki/includes/installer/DatabaseUpdater.php(690): Database->sourceFile(string)
#4 /wiki/includes/installer/MysqlUpdater.php(364): DatabaseUpdater->applyPatch(string, boolean, string)
#5 /wiki/includes/installer/DatabaseUpdater.php(472): MysqlUpdater->doInterwikiUpdate()
#6 /wiki/includes/installer/DatabaseUpdater.php(433): DatabaseUpdater->runUpdates(array, boolean)
#7 /wiki/maintenance/update.php(172): DatabaseUpdater->doUpdates(array)
#8 /wiki/maintenance/doMaintenance.php(111): UpdateMediaWiki->execute()
#9 /wiki/maintenance/update.php(217): require_once(string)
#10 {main}

It seems that the update.php were failed to detect the exist of tables in shared database, which resulting attempts to create tables that already exist in shared database.
(wrong sql patch used include but not limited to: patch-antispoof.mysql.sql, patch-interwiki.sql, patch-user_groups.sql, and patch-user_properties.sql )

MediaWiki 1.28.0 (bd2f326) 2017-1-21 12:10
PHP 7.0.15-1~dotdeb+8.1 (fpm-fcgi)
MySQL 5.5.53-0+deb8u1-log

Event Timeline

Zoglun created this task.Jan 31 2017, 11:44 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 31 2017, 11:44 PM
Zoglun updated the task description. (Show Details)Jan 31 2017, 11:49 PM

I'm seeing this exact behavior trying to run update.php on a 1.28.2 installation. Without the --doshared option, it completes without complaint. When I add in the --doshared, it collides with the existing interwiki table.

Same issue reported at T158154