Last modified: 2014-05-10 10:34:10 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T31635, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 29635 - update.php for Postgres creates sequences, then fails when it to rename sequences to those same names
update.php for Postgres creates sequences, then fails when it to rename seque...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Installer (Other open bugs)
1.19.2
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks: postgres
  Show dependency treegraph
 
Reported: 2011-06-28 23:07 UTC by Andy Lester
Modified: 2014-05-10 10:34 UTC (History)
12 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to skip existent sequence and throw a warning (737 bytes, patch)
2011-08-16 10:45 UTC, Luigi Corsaro
Details
Fixup databases where the problem already occurred (2.55 KB, patch)
2012-10-09 12:22 UTC, Thorsten Glaser
Details

Description Andy Lester 2011-06-28 23:07:04 UTC
In includes/installer/PostgresUpdater.php, there's a function getCoreUpdateList() that returns a list of actions for the updater to take.

There are two actions of adding new sequences:

array( 'addSequence', 'logging_log_id_seq'          ),
array( 'addSequence', 'page_restrictions_pr_id_seq' ),

However, after that, it's specified to rename existing sequences to those very names:

array( 'renameSequence', 'log_log_id_seq',      'logging_log_id_seq'          ),
array( 'renameSequence', 'pr_id_val',           'page_restrictions_pr_id_seq' ),

Since the updater just created logging_log_id_seq, trying to rename log_log_id_seq to logging_log_id_seq fails.

I commented out the top two lines, dropped the sequence logging_log_id_seq that had been created, and now my update runs correctly, and the old sequence gets a new name.
Comment 1 Luigi Corsaro 2011-08-16 10:45:38 UTC
Created attachment 8922 [details]
Patch to skip existent sequence and throw a warning

I've resolved and tested, it seems to work
Comment 2 Mark A. Hershberger 2011-08-16 19:12:19 UTC
Your patch removes some non-existent code.  Perhaps you meant it should be added?
Comment 3 Sam Reed (reedy) 2011-11-20 17:55:07 UTC
--- /home/www-data/wiki/tf2m/includes/installer/PostgresUpdater.php     2011-08-16 12:34:08.000000000 +0200
+++ /home/www-data/wiki/mediawiki-1.17.0/includes/installer/PostgresUpdater.php 2011-06-10 13:55:23.000000000 +0200

Looks like it might be diffing the wrong way...

r103766
Comment 4 Sumana Harihareswara 2011-11-21 09:09:45 UTC
Thanks for the patch, Luigi.
Comment 5 Max 2011-11-21 11:18:28 UTC
But is this really fixing the problem? Sure, the patch will prevent the updater to crash. But shouldn't also the real problem be addressed? I'm new to this hole Postgres thing so I can't say how this impacts but in my opinion:

- either the new sequences get created and the the old ones are no longer renamed
- the new sequences are not created but instead the old ones are renamed.

I'm suffering to the sequences mention by Andy in the bug description.
Comment 6 Max 2011-11-21 16:00:33 UTC
Except for the fact that my previous comment looks like it was written by a complete moron, here's my 2 cent on this: I was having problems with uploading files, kept getting an error:

Database error
A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:
(SQL query hidden)
from within function "LogPage::saveContent". Database returned error "1: ERROR: duplicate key value violates unique constraint "logging_pkey"".

After removing the two actions of adding new sequences and just letting the script rename the old ones uploading files was working again.
Comment 7 Thorsten Glaser 2012-10-09 12:20:48 UTC
Thanks, your analysis of the problem is correct.
However, the issue is *not* fixed, especially not for people who upgraded within the timeframe where it occurred, but also because due to your change, the sequence is *not* renamed, but a new one is created and the old one kept.

I’ve prepared a patch that can be used to addOrRenameSequence() in the future and fixes up this very specific situation. (I’ve got 238 MediaWiki instances on our farms and am so not going to do that manually.)

I’ve tested this on a development system instance so far, and it looks working, but would love to have it discussed before I upload it to Debian and try to get the Release Team to do another freeze exception.

Thanks in advance!
Comment 8 Thorsten Glaser 2012-10-09 12:22:04 UTC
Created attachment 11168 [details]
Fixup databases where the problem already occurred
Comment 9 Marcin Cieślak 2012-10-09 15:40:48 UTC
Are you using 1.17?

This should have been fixed in March 2012 in master (git commit f752cf80423615b380cf5612a3f1f68a6b9d0173).

Can you try that version of PostgresUpdater.php?

I was testing those changes by upgrading MediaWiki 1.7 to master using PostgresUpdater and it worked fine for me.
Comment 10 Thorsten Glaser 2012-10-15 15:23:42 UTC
I’m using 1.19.2.

The commit f752cf80423615b380cf5612a3f1f68a6b9d0173 will *not* fix the issue, because there’s still an

                        array( 'addSequence', 'logging_log_id_seq'          ),
                        array( 'addSequence', 'page_restrictions_pr_id_seq' ),

*before* the

                        array( 'renameSequence', 'log_log_id_seq',      'logging_log_id_seq'          ),

calls. Furthermore, once this code has been run, i.e. anyone who upgraded an 1.19 release from e.g. 1.15, *two* sequences exist, so the fixup patch I submitted (except the last [5~ line, that was editor junk) is still required.
Comment 11 Amir Sagie 2012-12-22 17:56:31 UTC
Attachment 11168 [details] confirmed to fix things when upgrading from mediawiki 1.15 to 1.19.2, postgresql 9.1.3, after update.php first introduced the problem.

with PostgresUpdater.php patched, and maintenance/update.php invoked for a second time, things seem to be back in order, with the mediawiki schema containing a total of 13 named sequences rather than 15 with two pairs of similarly named sequences.
Comment 12 Sumana Harihareswara 2012-12-28 00:54:04 UTC
Great, Amir! Can you go ahead and put that patch in Git? https://www.mediawiki.org/wiki/How_to_contribute will give you the information you need.  Thanks!
Comment 13 Umherirrender 2014-05-10 10:34:10 UTC
Fixed by Gerrit change #3365/Gerrit change #4672 where the addSequences was moved after the renameSequences.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links