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 1f3UwG-0000Gu-Lr for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Apr 2018 23:02:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3UwD-00008V-3N for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Apr 2018 23:02:01 +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 1f3UwB-00008L-3C for pgsql-hackers@lists.postgresql.org; Tue, 03 Apr 2018 23:02:00 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3Uw5-0003sy-Rd for pgsql-hackers@postgresql.org; Tue, 03 Apr 2018 23:01:58 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 7500E2113B; Tue, 3 Apr 2018 19:01:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 03 Apr 2018 19:01:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=86ZOlf1loYWSD5HgbcnXNtp28nPLxij3N3WIJNmsKbg=; b=nRT1C8QD KUQ2yrLt5QZ94NoBo8v/K4sToRGpKiLKjeAYymMo7SmKotq8qUy2T6AhS69kfGOz 0wnrHJL9vlLchYLPGmRhza6MJfVMiBxzhX4upruO+aXUAkrkvCNZKP5/Vn2nfMTk yRLh2QrrPe7GQjv5qGxfHezJz5nhPeO7mEl7qkkZbYl9mpK0iEQ58OMfNT4dmlaU yXOcG2kCCxXBumIyEZFitsksuTxhMGLwLrqdw9KRUQ3LCo6TSZzIozL8KYv71eGQ xeWxMlkW982pxyzjHvUiR1Zczo3zWohHvQUwS+WsjrPFzob0fsI773Iqbtld9xYk b3/rGa+zra3LKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=86ZOlf1loYWSD5HgbcnXNtp28nPLx ij3N3WIJNmsKbg=; b=bH3RSVCH9Jb3J7FqPOaVJh6Tr8ypMqNBLib/T/aaISBRd VYynFw8dZC5Y1ym+YuZTMWYMrt4LcFvBnQGXozQRgymxHs+ttj51LQnkLgxmyjEu Hvbrk6XC6Tw5JnHkeDGaXEAJrkwiPAPZrtDfJMAi3dvRH2OM68kvcyDTZ5lUmzEv nZRyCd3B6NI7FZArhYtg12jrRPGFbt8/iEkAITCBa1WNrYlgT3CdricYlkexMuzJ fDvXd98v17uPx5G0NKY2nown+SfgVb9MFFt7KaCJ4EWW3QxB+dSBAMPHabq4Qh46 ktiF1RyD4I5MPIhcH0VH1F6jM/Gi5Fze6xB+L8Guw== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 2AC0610251; Tue, 3 Apr 2018 19:01:51 -0400 (EDT) Date: Tue, 3 Apr 2018 16:01:50 -0700 From: Andres Freund To: Amit Kapila Cc: amul sul , Stephen Frost , Robert Haas , PostgreSQL-development Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key Message-ID: <20180403230150.b564ihenfuktt7cp@alap3.anarazel.de> References: <20180305232353.gpue7jldnm4bjf4i@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-03-06 19:57:03 +0530, Amit Kapila wrote: > On Tue, Mar 6, 2018 at 4:53 AM, Andres Freund wrote: > > Hi, > > > >> diff --git a/src/backend/executor/nodeLockRows.c b/src/backend/executor/nodeLockRows.c > >> index 7961b4be6a..b07b7092de 100644 > >> --- a/src/backend/executor/nodeLockRows.c > >> +++ b/src/backend/executor/nodeLockRows.c > >> @@ -218,6 +218,11 @@ lnext: > >> ereport(ERROR, > >> (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), > >> errmsg("could not serialize access due to concurrent update"))); > >> + if (!BlockNumberIsValid(BlockIdGetBlockNumber(&((hufd.ctid).ip_blkid)))) > >> + ereport(ERROR, > >> + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), > >> + errmsg("tuple to be locked was already moved to another partition due to concurrent update"))); > >> + > > > > Why are we using ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE rather than > > ERRCODE_T_R_SERIALIZATION_FAILURE? A lot of frameworks have builtin > > logic to retry serialization failures, and this kind of thing is going > > to resolved by retrying, no? > > > > I think it depends, in some cases retry can help in deleting the > required tuple, but in other cases like when the user tries to perform > delete on a particular partition table, it won't be successful as the > tuple would have been moved. So? In that case the retry will not find the tuple, which'll also resolve the issue. Preventing frameworks from dealing with this seems like a way worse issue than that. Greetings, Andres Freund