Re: restore pg_dumpall problem with update 7.0.3 to 7.1.1 - Mailing list pgsql-general

From Tom Lane
Subject Re: restore pg_dumpall problem with update 7.0.3 to 7.1.1
Date
Msg-id 13533.991071343@sss.pgh.pa.us
Whole thread Raw
In response to restore pg_dumpall problem with update 7.0.3 to 7.1.1  ("holtzman" <fill-in-the-blanks_@_._>)
List pgsql-general
"holtzman" <fill-in-the-blanks_@_._> writes:
> [pg_dumpall script fails with]
>   psql:dump_file:11: ERROR:  CREATE DATABASE: source database "template1" is
> being accessed by other users

Hm.  There is a bit of a race condition here, perhaps --- the pg_dumpall
script does

    \connect template1 $DBOWNER
    CREATE DATABASE foo;

and in the case of the very first database in the dump, the \connect is
redundant: before the \connect we were connected to template1 already.
In that case the old backend might not have finished shutting down by
the time the CREATE is issued, leading to this complaint.

This problem won't arise in dumps made with 7.1 pg_dump since they
will refer to template0, not template1, as the source for the CREATE
DATABASE copy ... and there shouldn't ever be anyone connected to
template0.

Evidently there is a risk with 7.0 dump scripts being brought forward,
however.  Removing the redundant \connect command may do as a workaround
for them.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Simple SQL question, need help.
Next
From: "Dave Cramer"
Date:
Subject: Re: Seq Scan