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 1f4Af0-0006eg-IC for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 19:35:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4Aez-0002I7-C5 for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Apr 2018 19:35:01 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4Aez-0002Hx-1d for pgsql-hackers@lists.postgresql.org; Thu, 05 Apr 2018 19:35:01 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4Aew-0005yN-4V for pgsql-hackers@postgresql.org; Thu, 05 Apr 2018 19:34:59 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id E9F94FA9; Thu, 5 Apr 2018 15:34:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 05 Apr 2018 15:34:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=pdkz8ZZ09rd/cetKg 2qcuWQxImjRZLxb/6dbeHLKQWc=; b=FH74vZrd4Y538mGT1MychKqLVW5KXYgkS QW3AVatuiaJ92xzaa4c8XWd2ZX4UPZQcfhBsqL9/UQ3+F3XrUvBwODjXQHsVY1Rf zmutGDD4GO63TdtfvAcumZPCGBwib8tvLrOBPRw4FRJqba59cFGufpjQsfFslr61 1RHNCUrmwlUI25WN3yBcyL5UY3uQdSbYOCmL5/iw1+M8dpPto91u3CjXW7dSGwUM nBuWJK067Rc5+dhcXW6quiPpJhgaQup4JqfW7JOAjBA6cC4vY5YxzZIH46ZxxHz2 7TjHsbyLDM+0XMkn4U0d0GPuo7Q4Z5zbphIzfpmd2JlHaWiW5oGbw== X-ME-Sender: Received: from alvin.alvh.no-ip.org (unknown [179.56.29.253]) by mail.messagingengine.com (Postfix) with ESMTPA id 37596E47F2; Thu, 5 Apr 2018 15:34:56 -0400 (EDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 1C98E71B; Thu, 5 Apr 2018 16:34:54 -0300 (-03) Date: Thu, 5 Apr 2018 16:34:54 -0300 From: Alvaro Herrera To: Pavan Deolasee Cc: Andres Freund , Robert Haas , Tom Lane , amul sul , Amit Kapila , Stephen Frost , PostgreSQL-development Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key Message-ID: <20180405193454.el2bffwijtsa7rbg@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Pavan Deolasee wrote: > On Thu, Apr 5, 2018 at 7:14 AM, Andres Freund wrote: > + /* > + * As long as we don't support an UPDATE of INSERT ON CONFLICT for > + * a partitioned table we shouldn't reach to a case where tuple to > + * be lock is moved to another partition due to concurrent update > + * of the partition key. > + */ > + Assert(!ItemPointerIndicatesMovedPartitions(&hufd.ctid)); > + > > This is no longer true; at least not entirely. We still don't support ON > CONFLICT DO UPDATE to move a row to a different partition, but otherwise it > works now. See 555ee77a9668e3f1b03307055b5027e13bf1a715. Right. So I think the assert() should remain, but the comment should say "As long as we don't update moving a tuple to a different partition during INSERT ON CONFLICT DO UPDATE on a partitioned table, ..." FWIW I think the code flow is easier to read with the renamed macros. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services