Topic on Project:Support desk

Error in update from 1.23.11 to 1.32.0

7
RrogersCalibr (talkcontribs)

I've been working on migrating my wiki from one server to another. The old server is on version 1.23.11, while the new server I'm attempting to migrate has version 1.32.0. When attempting to run update.php I get the following output:


"

MediaWiki 1.32.0 Updater

Your composer.lock file is up to date with current dependencies!

Going to run database updates for my_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

...skipping: 'mwuser' table doesn't exist yet.

...skipping: 'mwuser' table doesn't exist yet.

...skipping: 'pagecontent' table doesn't exist yet.

...sequence logging_log_id_seq already exists.

...sequence page_restrictions_pr_id_seq already exists.

Creating sequence filearchive_fa_id_seq

[71c46908d4ca49beddc58f98] [no req]   Wikimedia\Rdbms\DBQueryError from line 1496 of /var/www/html/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 SEQUENCE filearchive_fa_id_seq OWNED BY filearchive.fa_id

Function: Wikimedia\Rdbms\Database::query

Error: 42P01 ERROR:  relation "filearchive" does not exist

Backtrace:

#0 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1466): Wikimedia\Rdbms\Database->makeQueryException(string, string, string, string)

#1 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1226): Wikimedia\Rdbms\Database->reportQueryError(string, string, string, string, boolean)

#2 /var/www/html/wiki/includes/installer/PostgresUpdater.php(772): Wikimedia\Rdbms\Database->query(string)

#3 /var/www/html/wiki/includes/installer/DatabaseUpdater.php(485): PostgresUpdater->addSequence(string, string, string)

#4 /var/www/html/wiki/includes/installer/DatabaseUpdater.php(449): DatabaseUpdater->runUpdates(array, boolean)

#5 /var/www/html/wiki/maintenance/update.php(203): DatabaseUpdater->doUpdates(array)

#6 /var/www/html/wiki/maintenance/doMaintenance.php(94): UpdateMediaWiki->execute()

#7 /var/www/html/wiki/maintenance/update.php(248): require_once(string)

#8 {main}

"


If I look at my database, I can see that a 'filearchive' table does exist. I'm not too sure how to proceed from here. Any assistance would be very welcome and appreciated.

AssetDenmark (talkcontribs)

For what it's worth I managed to migrate using SQL export/import from/to myPHPadmin... i setup the 1.32 version the same (same extensions etc.) and then I was able to export (1.18) tables and import them - and I have since been running the update procedure several times.

TheDJ (talkcontribs)

Judging from the log, this seems like the very first modification that the upgrader is trying to make to your database. So possibly, your db user has enough permissions to read, but not to read/modify sequences ???

RrogersCalibr (talkcontribs)

Thanks for your input, it lead me in the right direction. I just figured out why this was occurring. My Wiki's schema was outside the user's search_path, so the table name wasn't recognized.


After fixing that and running update.php again, I made it significantly farther through the update, but it eventually ran into another error. I can post the full output if you'd like, but this seems to be the relevant portions of it:


"

Populating el_index_60 field, printing progress markers. For large

databases, you may want to hit Ctrl-C and do this manually with

maintenance/populateExternallinksIndex60.php.

Populating externallinks.el_index_60...

el_id 0 - 200 of 94

[83958a8835cbe5d376f98506] [no req]   Wikimedia\Rdbms\DBQueryError from line 1496 of /var/www/html/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: UPDATE IGNORE "externallinks" SET el_index_60 = 'http://org.wikimedia.meta./wiki/Help:Contents' WHERE el_id = '1'

Function: PopulateExternallinksIndex60::doDBUpdates

Error: 42P01 ERROR:  relation "ignore" does not exist

LINE 1: ...allinksIndex60::doDBUpdates calibrit@clearb... */ IGNORE "ex...

                                                             ^

Backtrace:

#0 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1466): Wikimedia\Rdbms\Database->makeQueryException(string, string, string, string)

#1 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1226): Wikimedia\Rdbms\Database->reportQueryError(string, string, string, string, boolean)

#2 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(2112): Wikimedia\Rdbms\Database->query(string, string)

#3 /var/www/html/wiki/maintenance/populateExternallinksIndex60.php(76): Wikimedia\Rdbms\Database->update(string, array, array, string, array)

#4 /var/www/html/wiki/maintenance/Maintenance.php(1698): PopulateExternallinksIndex60->doDBUpdates()

#5 /var/www/html/wiki/includes/installer/DatabaseUpdater.php(1374): LoggedUpdateMaintenance->execute()

#6 /var/www/html/wiki/includes/installer/DatabaseUpdater.php(485): DatabaseUpdater->populateExternallinksIndex60()

#7 /var/www/html/wiki/includes/installer/DatabaseUpdater.php(449): DatabaseUpdater->runUpdates(array, boolean)

#8 /var/www/html/wiki/maintenance/update.php(203): DatabaseUpdater->doUpdates(array)

#9 /var/www/html/wiki/maintenance/doMaintenance.php(94): UpdateMediaWiki->execute()

#10 /var/www/html/wiki/maintenance/update.php(248): require_once(string)

#11 {main}

"


Searching around I've found a couple other people mention this issue with ignore not existing, but haven't seen a solution. In contrast to the previous issue, it does appear that the "ignore" table really does not exist, from what I see. That's probably expected though, because it looks like IGNORE is trying to modify UPDATE, not tell it to UPDATE the "ignore" table.


Its also probably worth mentioning that I'm using a Postgresql database.

RrogersCalibr (talkcontribs)

I have managed to remedy this problem. I started working from a patch I found on https://phabricator.wikimedia.org/T130634 by jjanes. The solution was for a much older version and some of the method calls were no longer functioning as written. With a few modifications I was able to get the patch to 'includes/libs/database//DatabasePostgres.php' working. Below is what I added to the file to make it work, and allow update.php to successfully finish:

Add the following line to the includes at the beginning of the file:


use Psr\Log\NullLogger;


Add the following method to the file:

/**

* UPDATE wrapper. Takes a condition array and a SET array.

*

* @param string $table Name of the table to UPDATE. This will be passed through

*   DatabaseBase::tableName().

* @param array $values An array of values to SET. For each array element,

*   the key gives the field name, and the value gives the data to set

*   that field to. The data will be quoted by DatabaseBase::addQuotes().

* @param array $conds An array of conditions (WHERE). See

*   DatabaseBase::select() for the details of the format of condition

*   arrays. Use '*' to update all rows.

* @param string $fname The function name of the caller (from __METHOD__),

*   for logging and profiling.

* @param array $options An array of UPDATE options, can be:

*   - IGNORE: Ignore unique key conflicts

*   - LOW_PRIORITY: Not implemented for this database.

* @return bool

*/

function update( $table, $values, $conds, $fname = __METHOD__, $options = [] ) {

$table = $this->tableName( $table );

$sql = "UPDATE $table SET " . $this->makeList( $values, LIST_SET );

if ( $conds !== [] && $conds !== '*' ) {

$sql .= " WHERE " . $this->makeList( $conds, LIST_AND );

}

// If IGNORE is set, we use savepoints to emulate mysql's behavior

$savepoint = null;

if ( in_array( 'IGNORE', $options ) ) {

$logger = new NullLogger();

$savepoint = new SavepointPostgres( $this, 'mw', $logger );

$olde = error_reporting( 0 );

$savepoint->savepoint();

}

$res = (bool)$this->query( $sql, $fname, $savepoint );

if ( $savepoint ) {

$bar = pg_last_error();

if ( $bar != false ) {

$savepoint->rollback();

} else {

$savepoint->release();

}

error_reporting( $olde );

$savepoint->commit();

// IGNORE always returns true

return true;

}

return $res;

}

182.239.180.188 (talkcontribs)

I had the same error - updating to 1.32.1 on Fedora 30 / Postgresql. Being a bit confused by the suggested patches, I tracked the source of the error to the "ignore" qualifier in PopulateExternallinksIndex60->doDBUpdates(), around line 76 of populateExternallinksIndex60.php in maintennance, and removed it. It was clearly never going to do anything by raise a syntax error in postgresql, and, without studying the db in detail, I couldn't see why it was needed. In any case, it may not be the best or proper solution, but it worked !



Lkmorlan (talkcontribs)

I had the error "sequence logging_log_id_seq already exists". In my case, several sequences, functions, and a type where in schema "mediawiki" while the rest was in schema "public". I moved everything to "public" and the update script worked perfectly. Changing the search path might also fix it. Examples of the commands I used are here: https://phabricator.wikimedia.org/T148628#6081929

Reply to "Error in update from 1.23.11 to 1.32.0"