pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lincoln Yeoh <lyeoh@pop.jaring.my>
To: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-general@postgresql.org
Subject: Re: conditional insert
Date: Thu, 08 Sep 2011 22:31:39 +0800
Message-ID: <20110908143203.0C3AFB5DBCB@mail.postgresql.org> (raw)
In-Reply-To: <20110907200454.GV35347@shinkuro.com>
References: <j4261h$lj8$1@dough.gmane.org>
	<CADFuJLi3K0X1A7OwR+9_neWjKCEXtYYyMP_n=x5z=D2+GNCTNw@mail.gmail.com>
	<4E64A79E.7030503@compulab.co.il>
	<CADFuJLjfHUMEuYTPKgG6GtJMfzJeeq3-bkt162RywRVqc7OYgg@mail.gmail.com>
	<4E64AC45.6030704@rem.nl>
	<20110906190548.433E8B5DBD1@mail.postgresql.org>
	<CAHyXU0zSE4aVoZhXL9i8hnSjRaJwOpmcrV+jfLKKY=OCdXhR6A@mail.gmail.com>
	<CAHyXU0x3jMadwoZFW8S5+g04VjBGURNUnEYN4ZzhmAy5CQaTGw@mail.gmail.com>
	<4e679195.12848e0a.019e.ffff918eSMTPIN_ADDED@mx.google.com>
	<CAHyXU0w__hAwXRujM_JxF-4tg_hRYc4JCY_-_3DiyjzE2aYR+w@mail.gmail.com>
	<20110907200454.GV35347@shinkuro.com>

At 04:04 AM 9/8/2011, Andrew Sullivan wrote:
>On Wed, Sep 07, 2011 at 02:51:32PM -0500, Merlin Moncure wrote:
> >
> > @andrew s: going SERIALIZABLE doesn't help if you trying to eliminate
> > cases that would push you into retrying the transaction.
>
>Well, no, of course.  But why not catch the failure and retry?  I
>guess I just don't get the problem, since I hear people say this all
>the time.  (I mean, I've also seen places where 'upsert' would be
>cool, but it doesn't seem trivial to do in a general way and you can
>do this with catch-serialization-error-and-retry, I think?)

Doesn't catching the failure and retrying mean writing more code?

Need extra code:
1) to handle the savepoint.
2) to correctly distinguish between "retryable" errors and 
"nonretryable" errors.
3) to retry transactions.

More code to debug, test, document and support :).

In contrast, the "lock table, insert if row does not exist, update if 
it exists" and rollback everything if "stuff happens" seems simpler 
to do correctly.

I personally prefer to leave as much code writing to others (e.g. 
those writing Postgresql, programming languages and libraries), 
because I assume they are much better at writing code than I am. Plus 
I usually don't have to document and support their code ;).

Regards,
Link.





view thread (36+ messages)  latest in thread

Message-ID: <20110908143203.0C3AFB5DBCB@mail.postgresql.org>
Permalink:  ../20110908143203.0C3AFB5DBCB@mail.postgresql.org/
Also on:    postgresql.org/message-id/20110908143203.0C3AFB5DBCB@mail.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: lyeoh@pop.jaring.my, ajs@crankycanuck.ca
  Subject: Re: conditional insert
  In-Reply-To: <20110908143203.0C3AFB5DBCB@mail.postgresql.org>
  References: <j4261h$lj8$1@dough.gmane.org> <CADFuJLi3K0X1A7OwR+9_neWjKCEXtYYyMP_n=x5z=D2+GNCTNw@mail.gmail.com> <4E64A79E.7030503@compulab.co.il> <CADFuJLjfHUMEuYTPKgG6GtJMfzJeeq3-bkt162RywRVqc7OYgg@mail.gmail.com> <4E64AC45.6030704@rem.nl> <20110906190548.433E8B5DBD1@mail.postgresql.org> <CAHyXU0zSE4aVoZhXL9i8hnSjRaJwOpmcrV+jfLKKY=OCdXhR6A@mail.gmail.com> <CAHyXU0x3jMadwoZFW8S5+g04VjBGURNUnEYN4ZzhmAy5CQaTGw@mail.gmail.com> <4e679195.12848e0a.019e.ffff918eSMTPIN_ADDED@mx.google.com> <CAHyXU0w__hAwXRujM_JxF-4tg_hRYc4JCY_-_3DiyjzE2aYR+w@mail.gmail.com> <20110907200454.GV35347@shinkuro.com> <20110908143203.0C3AFB5DBCB@mail.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox