Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WrW9F-0000d1-13 for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Jun 2014 17:35:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WrW9E-00055e-Gi for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Jun 2014 17:35:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WrW9D-00055U-Tx for pgsql-bugs@postgresql.org; Mon, 02 Jun 2014 17:35:47 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WrW96-0005SF-Do for pgsql-bugs@postgresql.org; Mon, 02 Jun 2014 17:35:46 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id B3725500001; Mon, 2 Jun 2014 19:35:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-6.1 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC5EA4.dip0.t-ipconnect.de [93.220.94.164]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 9DD1D4E8006; Mon, 2 Jun 2014 19:35:36 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 278E5100923; Mon, 2 Jun 2014 19:35:36 +0200 (CEST) Date: Mon, 2 Jun 2014 19:35:36 +0200 From: Andres Freund To: Alvaro Herrera , Robert Haas Cc: Tom Lane , pgsql-bugs@postgresql.org, Sandro Santilli Subject: Re: uninterruptable loop: concurrent delete in progress within table Message-ID: <20140602173536.GE24145@awork2.anarazel.de> References: <20140530143150.GA11051@localhost> <20140531132841.GC1220@awork2.anarazel.de> <20140602164800.GA5146@eldon.alvh.no-ip.org> <20140602170820.GB24145@awork2.anarazel.de> <20140602172716.GC5146@eldon.alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140602172716.GC5146@eldon.alvh.no-ip.org> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2014-06-02 13:27:17 -0400, Alvaro Herrera wrote: > Andres Freund wrote: > > On 2014-06-02 12:48:01 -0400, Alvaro Herrera wrote: > > > Andres Freund wrote: > > > > > > > I do wonder if any of the other existing callers of HTSV are affected. I > > > > don't understand predicate.c well enough to be sure, but it looks to me > > > > like it'd could in theory lead to missed conflicts. Seems fairly > > > > unlikely to matter in practice though. > > > > > > One place where the difference in the new logic would cause a change is > > > the tupleIsAlive bit in IndexBuildHeapScan(), when building unique > > > indexes. Right now if the tuple is inserted by a remote running > > > transaction, and updated by it, we return DELETE_IN_PROGRESS, so we set > > > tupleIsAlive = false; so we wouldn't block if we see a tuple with that > > > value elsewhere. If we instead return INSERT_IN_PROGRESS we set > > > tupleIsAlive = true, and we would block until the inserter is done. > > > > Hm. Maybe I am missing something, but if either INSERT or > > DELETE_IN_PROGRESS is returned for a unique index in > > IndexBuildHeapScan() we'll wait for the xmin/xmax respectively and > > recheck the tuple, right? That recheck will then return a non-ephemeral > > status. > > Yeah, that's how I interpret that maze of little loops using callbacks. > I don't think waiting on xmin is the same as waiting on xmax, however; > the xmin could stay running for a while, but the xmax could be an > quickly aborted subtransaction, for instance. It essentially is. If xmax aborts you still have to deal with an 'INSERT_IN_PROGRESS' tuple because, as you say, xmin is still running. That's essentially my point. INSERT_IN_PROGRESS isn't a wrong answer. > > > One thing I'm now wondering while reading this code is those cases where > > > XMAX_INVALID is not set, but the value in Xmax is InvalidXid. We have > > > discussed these scenarios elsewhere and the conclusion seems to be that > > > they are rare but possible and therefore we should cater for them. > > > > Is there really a situation where that combination is possible for > > XMAX_INVALID? I don't see how. > > I vaguely remember Robert described how would this work, even though the > precise details evidently escape me because I can't quite trace it now. > I can't remember what thread this was on, either. Robert: Do you remember that case? Alvaro: In the end it'd not be very harmful - if it happens TransactionIdDidCommit() will return false (there's special case code for it). > Yeah, I'm not saying this is a new bug; I was only reacting to your > suggestion that we dump all of tqual.c and rewrite it from scratch > (heh). Heh. Not going to start with that today. Especially not in a patch that needs to be backpatched :) Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs