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 1ettH0-0003VY-Fi for pgsql-jdbc@arkaria.postgresql.org; Thu, 08 Mar 2018 10:59:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ettGv-0005Hu-10 for pgsql-jdbc@arkaria.postgresql.org; Thu, 08 Mar 2018 10:59:41 +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 1ettGu-0005Hj-Nm for pgsql-jdbc@lists.postgresql.org; Thu, 08 Mar 2018 10:59:40 +0000 Received: from mail-wr0-f174.google.com ([209.85.128.174]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ettGq-0002pm-SW for pgsql-jdbc@postgresql.org; Thu, 08 Mar 2018 10:59:38 +0000 Received: by mail-wr0-f174.google.com with SMTP id l43so5225746wrc.2 for ; Thu, 08 Mar 2018 02:59:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=gFH9ib0IeHsw+HTsRuZUBusPLT0g/Xg7YIBzkJYI4Ls=; b=fTU+MweDWTM7DuG+m9WeOxPuhmx1Qk2AKeI6ZT2BIw9Ia7CJtlLEzL/28w/H0FQUWb 4Zac1DNBX59YbneQ9hy4/cD/FjcjLLKRc0dbrIC9UdUmZWi45RE9A878Uu58ABc5wn7e 0g2awmNMWhuZ9Q1FiprxZAXWUWLLD3FnllzkcvZTs+TeY7ZRQr9HtklxilpxuPPEsvFP KXnCMn1A2PNDak9Ygw0uCX7lE4ceIqob9YlknTt/Y2gqg8yjI6d+bs2BsVYUYCgLVKWs 1qfCPFPh4I6x+OjvcXCdXUGz7Zwyzt+Oj2O6N0HY8aX5Lisv4w+EofXilglkLl7CwRuK 1UiQ== X-Gm-Message-State: APf1xPDt7TDwuBlghjlPCoOFQQLRUDstyeaRv/6dg08hCw05/rmXjbS+ 8zIv7rAgjIrjMHAb7TLCwHSrJA== X-Google-Smtp-Source: AG47ELuRpMsbAkJ0yOy5AuIbDawt2PGmqNkYexCRm3N/fuglwkXH3lvZ3vZ8PZX5MRoLzBjGJmWlRw== X-Received: by 10.223.166.106 with SMTP id k97mr21969284wrc.64.1520506774201; Thu, 08 Mar 2018 02:59:34 -0800 (PST) Received: from f26lite (cpc115198-nmal23-2-0-cust249.19-2.cable.virginm.net. [81.97.152.250]) by smtp.gmail.com with ESMTPSA id l33sm2815401wrl.43.2018.03.08.02.59.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 02:59:33 -0800 (PST) Message-ID: <1520506772.4589.10.camel@redhat.com> Subject: Re: Handling transaction failure due to concurrency errors From: jwhiting@redhat.com To: Christopher BROWN Cc: pgsql-jdbc , Tom Lane Date: Thu, 08 Mar 2018 10:59:32 +0000 In-Reply-To: References: <26956.1520003407@sss.pgh.pa.us> <27574.1520004078@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.24.6 (3.24.6-1.fc26) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Christopher, On a side note you should look at the Byteman project. Byteman makes fault injection for testing purposes very easy. http://byteman.jboss.org/ In your case using Byteman gets round the effort involved to precisely re-create a failure scenario. Testing when your re-try logic kicks in (or not). Jeremy On Fri, 2018-03-02 at 16:27 +0100, Christopher BROWN wrote: > Tom, > > That's what I was looking for, so thanks, I'll give it a go. > > Best regards, > Christopher > > > > On 2 March 2018 at 16:21, Tom Lane wrote: > > 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 > >