Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UVQ4X-0005TH-P7 for pgsql-admin@arkaria.postgresql.org; Thu, 25 Apr 2013 17:35:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UVQ4X-0000GX-3x for pgsql-admin@arkaria.postgresql.org; Thu, 25 Apr 2013 17:35:05 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UVQ4W-0000Fe-94; Thu, 25 Apr 2013 17:35:04 +0000 Received: from moutng.kundenserver.de ([212.227.126.186]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UVQ4O-000433-Vr; Thu, 25 Apr 2013 17:35:03 +0000 Received: from anarazel.de (p5DDC4DB9.dip0.t-ipconnect.de [93.220.77.185]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0LknvV-1V5aEM2DtF-00ajj4; Thu, 25 Apr 2013 19:34:47 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 656351C00FA; Thu, 25 Apr 2013 19:34:46 +0200 (CEST) Date: Thu, 25 Apr 2013 19:34:46 +0200 From: Andres Freund To: Tom Lane Cc: Paul Hinze , pgsql-admin@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [HACKERS] Simultaneous index creates on different schemas cause deadlock? Message-ID: <20130425173446.GH11158@awork2.anarazel.de> References: <10635.1366910251@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10635.1366910251@sss.pgh.pa.us> X-Provags-ID: V02:K0:acvHDdXNTcHbbUGMpzVQhozBJYJQZIbyQvtr/fou/W9 iZbKTbmJL5MgBNCRNCl7Uj9bC0oq5+2otO1zDRtI8kmX7lfjsJ 3J/TehcbS94YD2c/Hx1FXHT3jo6qkpFgc8SuzBDGFwpF9zttAu i/gXql1LdC/Pu95sZ1ntHrzTOSbNZa8k9uHclawGVSr4f1cW46 8UgK7nh7b9IjhVADFtmV4pPTw4kR/FhTOpDMvdVL/xJFWacff+ 9A71sSBm+4CplRIkWyhWuzhyzRmXxLDy81+LDIZ1XnpTs6PQSa CwL3zRyVf5MV38ZY38CkyEdmOJ2qj0R4+pqyNbCpzhtOyAfyz1 SwYMZyYjYQdXXPETPHfWX6SX2ZYrksvTPYCIXUL/b X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org On 2013-04-25 13:17:31 -0400, Tom Lane wrote: > Paul Hinze writes: > > [ multiple CREATE INDEX CONCURRENTLY commands will deadlock with each other ] > > Hm. I guess the reason nobody noticed this before now is that generally > the idea with CREATE INDEX CONCURRENTLY is to minimize the impact on > system load, hence you wouldn't do more than one at a time. Still, it's > surely a POLA violation that you *can't* do more than one at a time. > > The cause is that each one will wait for all older snapshots to be > gone --- and it does that before dropping its own snapshot, so that the > other ones will see it as something to be waited out too. Makes sense. > Since we know that C.I.C. executes in its own transaction, and there > can't be more than one on the same table due to locking, it seems to me > that it'd be safe to drop our own snapshot before waiting for other > xacts to end. That is, we could just rearrange the last few steps in > DefineIndex(), taking care to save snapshot->xmin before we destroy the > snapshot so that we still have that value to pass to > GetCurrentVirtualXIDs(). > > Anybody see a flaw in that solution? Except that it still will unnecessarily wait for other CICs, just not deadlock, I don't see a problem. We could have a PROC_IN_CIC flag or something so we can ignore other index creations, but I am not sure if its worth the complication. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin