Page MenuHomePhabricator

Error upgrading from 1.15 to 1.16 on Postgres
Closed, ResolvedPublic

Description

From IRC:
<locriani> Warning: pg_query(): Query failed: ERROR: relation "cu_changes_cu_id_seq" already exists in /var/www/dfwiki/includes/db/DatabasePostgres.php on line 580


Version: 1.16.x
Severity: critical

Details

Reference
bz22767

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
InvalidNone
ResolvedTurnstep

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:01 PM
bzimport set Reference to bz22767.

What's the context - what were you doing when this occurred? What was the last thing output before this error message?

locriani wrote:

That's the only output from the update.php script. I was attempting to upgrade from 1.15 to 1.16.

qji wrote:

I tried upgrade from mediawiki 1.15.1 to 1.16.0.
I get this error when I run update.php:


Updating sequence names
Warning: pg_query(): Query failed: ERROR: syntax error at or near "RENAME"
LINE 1: ...aseBase::sourceStream */ SEQUENCE rev_rev_id_val RENAME TO ...

^ in /................/mediawiki-1.16.0/includes/db/DatabasePostgres.php on line 584

A database error has occurred
Query: ALTER SEQUENCE rev_rev_id_val RENAME TO revision_rev_id_seq

Function: DatabaseBase::sourceStream
Error: 1 ERROR: syntax error at or near "RENAME"

LINE 1: ...aseBase::sourceStream */ SEQUENCE rev_rev_id_val RENAME TO ...

My postgres version is 8.1 and I afraid, there isn't "ALTER SEQUENCE .... RENAME" comman on 8.1 only on 8.3 (and above).

http://www.postgresql.org/docs/8.1/static/sql-altersequence.html
http://www.postgresql.org/docs/8.3/static/sql-altersequence.html

PostgreSQL 8.1 isn't really supported?

I'll look into fixing this, but it is very likely that 8.1 will not be supported moving forward, as it is not going to be officially supported much longer.

locriani wrote:

My issue occurs with PG 8.4.

(In reply to comment #5)

My issue occurs with PG 8.4.

I think the issue you saw has already been fixed (indeed, I think the fix is *causing* the 8.1 issues!)

locriani wrote:

Whoops, indeed it has. My apologies for not actually paying attention!

sacher wrote:

Hi there,
we are using PGSQL 8.1.13 and MW 1.16.1 now.

The ALTER SEQUENCE x RENAME TO y; is not available with PGSQL 8.2 and below, it is a feature in PGSQL 8.3. Just change ALTER SEQUENCE into ALTER TABLE.

http://www.postgresql.org/docs/8.1/static/sql-altersequence.html
http://www.postgresql.org/docs/8.3/static/sql-altersequence.html

To use the updater you need to modify "... /maintenance/postgres/archives/patch-update_sequences.sql" as follows:

ALTER TABLE rev_rev_id_val RENAME TO revision_rev_id_seq;
ALTER TABLE revision ALTER COLUMN rev_id SET DEFAULT NEXTVAL('revision_rev_id_seq');

ALTER TABLE text_old_id_val RENAME TO text_old_id_seq;
ALTER TABLE pagecontent ALTER COLUMN old_id SET DEFAULT nextval('text_old_id_seq');

ALTER TABLE category_id_seq RENAME TO category_cat_id_seq;
ALTER TABLE category ALTER COLUMN cat_id SET DEFAULT nextval('category_cat_id_seq');

ALTER TABLE ipblocks_ipb_id_val RENAME TO ipblocks_ipb_id_seq;
ALTER TABLE ipblocks ALTER COLUMN ipb_id SET DEFAULT nextval('ipblocks_ipb_id_seq');

ALTER TABLE rc_rc_id_seq RENAME TO recentchanges_rc_id_seq;
ALTER TABLE recentchanges ALTER COLUMN rc_id SET DEFAULT nextval('recentchanges_rc_id_seq');

ALTER TABLE log_log_id_seq RENAME TO logging_log_id_seq;
ALTER TABLE logging ALTER COLUMN log_id SET DEFAULT nextval('logging_log_id_seq');

ALTER TABLE pr_id_val RENAME TO page_restrictions_pr_id_seq;
ALTER TABLE page_restrictions ALTER COLUMN pr_id SET DEFAULT nextval('page_restrictions_pr_id_seq');

Issue seems fixed except for 8.1, but we've dropped support for that with 1.17.

Going ahead and marking FIXED.

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.