Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YxcMJ-0008VG-N8 for pgsql-general@arkaria.postgresql.org; Wed, 27 May 2015 14:31:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YxcMJ-0008Aq-76 for pgsql-general@arkaria.postgresql.org; Wed, 27 May 2015 14:31:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YxcMH-00088w-Go for pgsql-general@postgresql.org; Wed, 27 May 2015 14:31:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1YxcMA-0001Ko-BN for pgsql-general@postgresql.org; Wed, 27 May 2015 14:31:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t4REUith031801; Wed, 27 May 2015 10:30:44 -0400 From: Tom Lane To: Adrian Klaver cc: Melvin Davidson , Mitu Verma , "pgsql-general@postgresql.org" Subject: Re: duplicate key value violates unique constraint "pg_class_relname_nsp_index" In-reply-to: <5565C775.3070609@aklaver.com> References: <84BC7AB0D621A74893EC9C9E151293B0226AD107@ESESSMB207.ericsson.se> <5565C775.3070609@aklaver.com> Comments: In-reply-to Adrian Klaver message dated "Wed, 27 May 2015 06:32:37 -0700" Date: Wed, 27 May 2015 10:30:44 -0400 Message-ID: <31800.1432737044@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Adrian Klaver 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