Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"
Дата
Msg-id 31800.1432737044@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index"  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-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


В списке pgsql-general по дате отправления:

Предыдущее
От: Andy Colson
Дата:
Сообщение: Re: Reg: BULK COLLECT
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Reg: BULK COLLECT