Re: pgbench - prevent client from aborting on ERROR

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "Nicholson, Brad (Toronto, ON, CA)" <bnicholson(at)hp(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pgbench - prevent client from aborting on ERROR
Date: 2015-04-30 19:01:11
Message-ID: 55427BF7.2030405@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/30/2015 11:36 AM, Nicholson, Brad (Toronto, ON, CA) wrote:
> Hi,
>
> Is there any way to do this?
>
> For context, I'm wanting to write a custom script in repeatable read isolation level. If I hit a serializable error, I don't want the client to abort, I want it to continue running transactions. Is that possible?

Catch the exception/error and retry:

http://www.postgresql.org/docs/9.4/interactive/transaction-iso.html#XACT-REPEATABLE-READ

"When an application receives this error message, it should abort the
current transaction and retry the whole transaction from the beginning.
The second time through, the transaction will see the
previously-committed change as part of its initial view of the database,
so there is no logical conflict in using the new version of the row as
the starting point for the new transaction's update.

>
> thanks,
> Brad.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dave Owens 2015-04-30 19:08:40 Re: database split
Previous Message William Dunn 2015-04-30 18:37:00 Re: PostgreSQL HA config recommendations