Re: pg_upgrade failing from 9.3 to 9.4 because "template0" already exists - Mailing list pgsql-general

From Stephen Frost
Subject Re: pg_upgrade failing from 9.3 to 9.4 because "template0" already exists
Date
Msg-id 20150306182638.GT29780@tamriel.snowman.net
Whole thread Raw
In response to pg_upgrade failing from 9.3 to 9.4 because "template0" already exists  (Matt Landry <lelnet.matt@gmail.com>)
List pgsql-general
Matt,

In your existing environment, do you have template0 set to allow
connections (datallowconn)?

That's not a good idea in general, but I suspect that's why pg_dumpall
is including it based on a quick look at the code.

Thanks!

* Matt Landry (lelnet.matt@gmail.com) wrote:
> Attempting to upgrade a large (>3TB) postgressql database from 9.3
> to 9.4 on Ubuntu 14.04 LTS, but the process fails fairly early on.
> The error message instructs me to look at the last few lines of
> pg_upgrade_utility.log for more info, and the last two lines there
> (the only ones that don't succeed) are:
>
> CREATE DATABASE "template0" WITH TEMPLATE = template0 OWNER = "postgres";
> psql:pg_upgrade_dump_globals.sql:44: ERROR:  database "template0"
> already exists
>
> For reference, the pg_upgrade command as I'm running it is:
>
> /usr/lib/postgresql/9.4/bin/pg_upgrade -k -b
> /usr/lib/postgresql/9.3/bin -B /usr/lib/postgresql/9.4/bin -d
> /DB/postgres/data/9.3/main -D /DB/postgres/data/9.4/main -o '-c
> config_file=/etc/postgresql/9.3/main/postgresql.conf' -O '-c
> config_file=/etc/postgresql/9.4/main/postgresql.conf'
>
> Searching google for useful advice yields...little. (Mostly articles
> about problems upgrading from 8.4 to 9.2, whose solutions -- when
> they're described -- don't help here. Also, there are a number of
> sources saying I should just do a pg_dumpall and then a
> pg_restore...which would be fine, probably, if I could afford to
> take my production database offline for a week.)
>
> I do have a pg_dumpall backup done, and at the moment I'm doing all
> this on a test instance, so I can afford to experiment without
> risking data corruption or excessive downtime on the production
> server, but the whole point of the experimenting is to come up with
> a procedure that will work in production when it's time to do it
> there. Dump-and-restore definitely does not meet that requirement,
> even if it does eventually recreate a working database.
>
> Any ideas? I'm sure I'm missing something obvious, here, but I can't
> seem to find any reference that tells me what it would be.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

Attachment

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: pg_upgrade failing from 9.3 to 9.4 because "template0" already exists
Next
From: Thomas Kellerer
Date:
Subject: Re: Problem JDBC, AutoCommit ON and SELECT FOR UPDATE