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 1ermUu-0000JO-9a for pgsql-jdbc@arkaria.postgresql.org; Fri, 02 Mar 2018 15:21:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ermUt-0001ic-5W for pgsql-jdbc@arkaria.postgresql.org; Fri, 02 Mar 2018 15:21:23 +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 1ermUs-0001iS-Vo for pgsql-jdbc@lists.postgresql.org; Fri, 02 Mar 2018 15:21:23 +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 1ermUq-0004Jb-C0 for pgsql-jdbc@postgresql.org; Fri, 02 Mar 2018 15:21:22 +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 w22FLIPY027575; Fri, 2 Mar 2018 10:21:18 -0500 From: Tom Lane To: Christopher BROWN cc: pgsql-jdbc Subject: Re: Handling transaction failure due to concurrency errors In-reply-to: References: <26956.1520003407@sss.pgh.pa.us> Comments: In-reply-to Christopher BROWN message dated "Fri, 02 Mar 2018 16:17:09 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27573.1520004078.1@sss.pgh.pa.us> Date: Fri, 02 Mar 2018 10:21:18 -0500 Message-ID: <27574.1520004078@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Christopher BROWN writes: > Thanks for the quick reply. OK for the explanation, and I don't mind > implementing the retry logic for this case... I just don't know how to > detect when my code encounters this case (as opposed to other cases that > can arise, such as unresolved foreign keys when importing data; I don't > want to get into an infinite retry loop because it will never work in these > other cases). Yes, you should only retry in this way for the specific case of a serialization failure (SQLSTATE 40001). regards, tom lane