Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WrVS2-0007k5-11 for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Jun 2014 16:51:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WrVS1-0003Gf-Ed for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Jun 2014 16:51:09 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WrVS0-0003GY-EW for pgsql-bugs@postgresql.org; Mon, 02 Jun 2014 16:51:08 +0000 Received: from smtprelay0217.b.hostedemail.com ([64.98.42.217] helo=smtprelay.b.hostedemail.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WrVRs-0004Lw-8F for pgsql-bugs@postgresql.org; Mon, 02 Jun 2014 16:51:06 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay01.b.hostedemail.com (Postfix) with ESMTP id D138C2D2B5D; Mon, 2 Jun 2014 16:50:58 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::::, RULES_HIT:41:355:379:599:966:967:973:988:989:1260:1277:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1534:1542:1593:1594:1595:1596:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2525:2553:2560:2563:2682:2685:2692:2828:2859:2895:2903:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4385:4605:4659:5007:6117:6119:6261:7903:8666:8957:9025:9121:10004:10400:10450:10455:10848:11026:11232:11256:11257:11473:11658:11914:12043:12296:12438:12517:12519:12663:13151:13161:13228:13229:13869: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: door81_7cd3356fc7e43 X-Filterd-Recvd-Size: 3095 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 16:50:57 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id 34DAB1FC9; Mon, 2 Jun 2014 12:48:01 -0400 (CLT) Date: Mon, 2 Jun 2014 12:48:01 -0400 From: Alvaro Herrera To: Andres Freund Cc: Tom Lane , pgsql-bugs@postgresql.org, Sandro Santilli Subject: Re: uninterruptable loop: concurrent delete in progress within table Message-ID: <20140602164800.GA5146@eldon.alvh.no-ip.org> References: <20140530143150.GA11051@localhost> <20140531132841.GC1220@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: <20140531132841.GC1220@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: > 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. I think it'd be better to ensure that DELETE_IN_PROGRESS is returned as appropriate in the new XidIsInProgress(xmin) block. > I have to say I really hate the amount of repetitive code inside the > individual visibility routines. Obviously it's nothing backpatchable and > may become moot to a certain degree with the CSN work, but those are > pretty close to being unmaintainable. 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. (IIRC the scenario is a tuple that is frozen without a full-page write and no checksums; if we crash before writing the buffer, we would recover the invalid value in Xmax but the hint bit would not become set. I think this is not possible anymore after we tweaked the freezing protocol.) So instead of a check like if (tuple->t_infomask & HEAP_XMAX_INVALID) we would have something like if (HeapTupleHeaderXmaxIsInvalid(tuple)) which checks both things -- and is easier to read, IMHO. -- Á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