Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1FFR-0001De-T8 for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Mar 2018 17:52:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f1FFQ-0006HA-BT for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Mar 2018 17:52:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1FFQ-0006H0-4L for pgsql-hackers@lists.postgresql.org; Wed, 28 Mar 2018 17:52:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1FFN-000309-DI for pgsql-hackers@postgresql.org; Wed, 28 Mar 2018 17:52:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w2SHqOGw001899; Wed, 28 Mar 2018 13:52:24 -0400 From: Tom Lane To: Andres Freund cc: Robert Haas , Pavan Deolasee , amul sul , Amit Kapila , Stephen Frost , PostgreSQL-development Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key In-reply-to: <20180328163541.l5ksnqmpn6bl4rg2@alap3.anarazel.de> References: <10896.1520521635@sss.pgh.pa.us> <8293.1520528639@sss.pgh.pa.us> <21103.1520534813@sss.pgh.pa.us> <20180328163541.l5ksnqmpn6bl4rg2@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 28 Mar 2018 09:35:41 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1897.1522259544.1@sss.pgh.pa.us> Date: Wed, 28 Mar 2018 13:52:24 -0400 Message-ID: <1898.1522259544@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-03-08 13:46:53 -0500, Tom Lane wrote: >> ... Breaking fundamental invariants like >> "ctid points to this tuple or its update successor" is going to cause >> trouble. There's a lot of code that knows that; more than knows the >> details of what's in xmax, I believe. > Given, as explained nearby, we already do store transient data in the > ctid for speculative insertions (i.e. ON CONFLICT), and it hasn't caused > even a whiff of trouble, I'm currently not inclined to see a huge issue > here. It'd be great if you could expand on your concerns here a bit, we > gotta figure out a way forward. Just what I said. There's a lot of code that knows how to follow tuple update chains, probably not all of it in core, and this will break it. But only in seldom-exercised corner cases, which is the worst of all possible worlds from a reliability standpoint. (I don't think ON CONFLICT is a counterexample because, IIUC, it's not a persistent state.) Given that there are other ways we could attack it, I think throwing away this particular invariant is an unnecessarily risky solution. >> I would've been happier about expending an infomask bit towards this >> purpose. Just eyeing what we've got, I can't help noticing that >> HEAP_MOVED_OFF/HEAP_MOVED_IN couldn't possibly be set in any tuple >> in a partitioned table. Perhaps making these tests depend on >> partitioned-ness would be unworkably messy, but it's worth thinking >> about. > They previously couldn't be set together IIRC, so we could just (mask & > (HEAP_MOVED_OFF |HEAP_MOVED_IN)) == (HEAP_MOVED_OFF |HEAP_MOVED_IN) but > that'd be permanently eating two infomask bits. Hmm. That objection only matters if we have realistic intentions of reclaiming those bits in future, which I've not heard anyone making serious effort towards. Rather than messing with the definition of ctid, I'd be happier with saying that they're never going to be reclaimed, but at least we're getting one bit's worth of real use out of them. regards, tom lane