Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WrX8v-0002KB-E4 for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Jun 2014 18:39:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WrX8u-0006uW-Me for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Jun 2014 18:39:32 +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 1WrX8u-0006uQ-2h for pgsql-bugs@postgresql.org; Mon, 02 Jun 2014 18:39:32 +0000 Received: from smtprelay0154.b.hostedemail.com ([64.98.42.154] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WrX8o-0006fB-VS for pgsql-bugs@postgresql.org; Mon, 02 Jun 2014 18:39:30 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay01.b.hostedemail.com (Postfix) with ESMTP id 6209D2D2A11; Mon, 2 Jun 2014 18:39:25 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::::::, RULES_HIT:41:355:379:599:967:973:988:989:1260:1277:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1534:1542:1593:1594:1595:1596:1605:1711:1730:1747:1777:1792:2198:2199:2393:2525:2560:2563:2682:2685:2692:2693:2736:2828:2859:2895:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:4659:5007:6117:6261:7903:8957:9025:9121:10004:10400:10450:10455:10848:10967:11026:11232:11256:11257:11473:11658:11914:12438:12517:12519:12663:12740:13161:13229:13618:13894:13895:19904:19999, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: lead53_34f6989343429 X-Filterd-Recvd-Size: 4194 Received: from eldon.alvh.no-ip.org (unknown [190.196.179.133]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf04.b.hostedemail.com (Postfix) with ESMTPA; Mon, 2 Jun 2014 18:39:23 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id A3B221FC9; Mon, 2 Jun 2014 14:39:22 -0400 (CLT) Date: Mon, 2 Jun 2014 14:39:22 -0400 From: Alvaro Herrera To: Andres Freund Cc: Robert Haas , Tom Lane , pgsql-bugs@postgresql.org, Sandro Santilli Subject: Re: uninterruptable loop: concurrent delete in progress within table Message-ID: <20140602183922.GF5146@eldon.alvh.no-ip.org> 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> <20140602173536.GE24145@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20140602173536.GE24145@awork2.anarazel.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) 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 Andres Freund wrote: > 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. Uh. Actually it strikes me that DELETE_IN_PROGRESS is a wrong answer in the XidIsInProgress(xmin) block anyhow. If the tuple is being inserted remotely, there is no way we can return DELETE_IN_PROGRESS, is there? We can never be sure that the deleting subxact is not going to abort. The only way for this transaction to say that the tuple is DELETE_IN_PROGRESS is if the *inserting* subtransaction is an aborted subxact; but we already tell that case apart. So DELETE_IN_PROGRESS is only a valid return in the new block, XidIsCurrentXact(xmin). Another thing I wanted to comment on originally is that I'm not sure about the CHECK_FOR_INTERRUPTS() additions. Aren't those only to serve the case of the current bug, or bugs of similar ilk? There is no way that a valid, non-bug situation is going to cause us to loop forever there. That said, there isn't much harm in having them there either, but I think I'd put them before the xact wait, not after. -- Álvaro Herrera 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