From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Melvin Davidson <melvin6925@gmail.com>
Cc: Mitu Verma <mitu.verma@ericsson.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
Date: Wed, 27 May 2015 10:30:44 -0400
Message-ID: <31800.1432737044@sss.pgh.pa.us> (raw)
In-Reply-To: <5565C775.3070609@aklaver.com>
References: <84BC7AB0D621A74893EC9C9E151293B0226AD107@ESESSMB207.ericsson.se>
<CANu8Fix9awzDHEJjcWnnqSxTESaAhkUMwRVN34GZzD-X0D3FyQ@mail.gmail.com>
<5565C775.3070609@aklaver.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 05/27/2015 06:05 AM, Melvin Davidson wrote:
>> What this indicates is that someone, or some thing, is trying to create
>> a table in a schema that already exists.
> The error you see in that situation is:
> postgres-2015-05-27 06:25:10.173 PDT-0ERROR: relation "table1" already
> exists
> postgres-2015-05-27 06:25:10.173 PDT-0STATEMENT: create table table1 (i
> int);
> Best guess is as Pete and Albe said, some user code is directly
> accessing pg_class or the index has been corrupted.
I don't think it's necessary to make such assumptions to explain the
errors. What is more likely is that two sessions are trying to create
identically named tables at about the same time. You do get the nice
user-friendly "already exists" error if the conflicting table was
committed before CREATE TABLE looks --- but in a concurrent-transactions
situation, neither CREATE TABLE will see the other's table as already
existing. In race conditions like this, it's the unique index on the
catalog that is the duplicate-preventer of last resort, and it's going
to throw this error.
regards, tom lane
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, melvin6925@gmail.com, mitu.verma@ericsson.com
Subject: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
In-Reply-To: <31800.1432737044@sss.pgh.pa.us>
References: <84BC7AB0D621A74893EC9C9E151293B0226AD107@ESESSMB207.ericsson.se> <CANu8Fix9awzDHEJjcWnnqSxTESaAhkUMwRVN34GZzD-X0D3FyQ@mail.gmail.com> <5565C775.3070609@aklaver.com> <31800.1432737044@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox