Re: Duplicate key issue in a transaction block

From: Ioana Danes <ioanasoftware(at)yahoo(dot)ca>
To: Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Duplicate key issue in a transaction block
Date: 2009-06-08 17:12:42
Message-ID: 915095.83936.qm@web45114.mail.sp1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- On Mon, 6/8/09, Bill Moran <wmoran(at)potentialtech(dot)com> wrote:

> From: Bill Moran <wmoran(at)potentialtech(dot)com>
> Subject: Re: [GENERAL] Duplicate key issue in a transaction block
> To: "Ioana Danes" <ioanasoftware(at)yahoo(dot)ca>
> Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
> Received: Monday, June 8, 2009, 12:33 PM
> In response to Ioana Danes <ioanasoftware(at)yahoo(dot)ca>:
> >
> > Hi Everyone,
> >
> > I have a hard to reproduce scenario for a production
> site....I tried to simplify the code and at the end I could
> get a similar problem with the following table and java
> code.
> > The problem is that I have a transaction that deletes
> all the records in a group and inserts the new records for
> that group. If that transaction is called from 2 different
> clients for the same groupid it happens to get a duplicate
> key violation which it should never happen on my
> opinion!!!!!!!!
>
> On what is that opinion based?  Considering the
> situation you describe, I
> would expect it to error every time you try to run that
> same script twice
> in parallel.

Well, you are right, I had a wrong understanding of Read Committed isolation level. I was expecting that my inserts will see only what was committed before the transaction begin not before the query begin.

Thanks for your answer...

__________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now
http://ca.toolbar.yahoo.com.

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2009-06-08 17:16:41 Re: [SQL] 'cost' and 'rows' for volitile function
Previous Message Vyacheslav Kalinin 2009-06-08 17:04:22 Re: Duplicate key issue in a transaction block