Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UVPne-0004Jo-43 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2013 17:17:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UVPnd-0004z0-FQ for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2013 17:17:37 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UVPnb-0004yo-4P; Thu, 25 Apr 2013 17:17:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UVPnZ-0003i3-1L; Thu, 25 Apr 2013 17:17:34 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r3PHHVGC010636; Thu, 25 Apr 2013 13:17:31 -0400 (EDT) From: Tom Lane To: Paul Hinze cc: pgsql-admin@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [ADMIN] Simultaneous index creates on different schemas cause deadlock? In-reply-to: References: Comments: In-reply-to Paul Hinze message dated "Tue, 23 Apr 2013 12:14:16 -0500" Date: Thu, 25 Apr 2013 13:17:31 -0400 Message-ID: <10635.1366910251@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-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org 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. 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? regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers