Re: deadlock problem in Ad serving.. - Mailing list pgsql-admin

From Ron Mayer
Subject Re: deadlock problem in Ad serving..
Date
Msg-id Pine.LNX.4.33.0301200949540.13721-100000@ron
Whole thread Raw
In response to Re: deadlock problem in Ad serving..  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: deadlock problem in Ad serving..
List pgsql-admin
On Mon, 20 Jan 2003, Tom Lane wrote:
>
> Bhuvan A <bhuvansql@myrealbox.com> writes:
> >> Error:...deadlock detected...
> > ... You can overcome this by locking the table in share row
> > exclusive mode also...
>
> ...use shorter transactions (one per page, not one per several pages).

Hmm... with his query:
  "update banner_stats set imp=imp+1 where uniqid=4330"

Is it true that the problem happens when updates are done
in a different order by two transactions like this:

 trans.1:  "update banner_stats set imp=imp+1 where uniqid=4330"
 trans.2:  "update banner_stats set imp=imp+1 where uniqid=10"
 trans.1:  "update banner_stats set imp=imp+1 where uniqid=10"
 trans.2:  "update banner_stats set imp=imp+1 where uniqid=4330"

If so, then could the problem be avoided if in his application
logic he always did the updates in the same order? ... I.e. Make
sure the each transaction does the updates in the same order by
sorting his updates based on uniqid in the client?

   Ron


pgsql-admin by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Installing on Sun machine
Next
From: "Christian Brink"
Date:
Subject: Re: deadlock problem in Ad serving..