Re: On duplicate ignore

From: Florian Weimer <fweimer(at)bfk(dot)de>
To: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
Cc: <gnanam(at)zoniac(dot)com>, "'Atul Goel'" <Atul(dot)Goel(at)iggroup(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: On duplicate ignore
Date: 2012-01-20 11:41:34
Message-ID: 821uqu8utt.fsf@mid.bfk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

* Lincoln Yeoh:

> Is there a simple way to get postgresql to retry a transaction, or
> does the application have to actually reissue all the necessary
> statements again?

The application has to re-run the transaction, which might result in the
execution of different statements. In the INSERT-or-UPDATE case, the
new attempt will have to use an UPDATE instead of an INSERT, so replying
the statements verbatim will not work.

> I'd personally prefer to use locking and selects to avoid transaction
> aborts whether due to unique constraint violations or due to
> serialization violations.

Once you address the restart issue, transactional code is simpler and
easier to check for correctness.

Restarting transactions has other benefits, too. For instance, you can
restart your PostgreSQL server process, and your applications will just
keep running.

--
Florian Weimer <fweimer(at)bfk(dot)de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brice Maron 2012-01-20 11:43:25 Immutable function with bind value
Previous Message Brice Maron 2012-01-20 11:15:16 Immutable function with bind value