pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ron Mayer <ron@intervideo.com>
Cc: Bhuvan A <bhuvansql@myrealbox.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: deadlock problem in Ad serving..
Date: Mon, 20 Jan 2003 15:20:12 -0500
Message-ID: <15369.1043094012@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.33.0301200949540.13721-100000@ron>
References: <Pine.LNX.4.33.0301200949540.13721-100000@ron>

Ron Mayer <ron@intervideo.com> writes:
> 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"

Yeah, I would assume that that's the problem.

> 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?

If I understood correctly, he's tracking webpage hits; so the updates
are going to correspond to the sequence in which visitors move to
different webpages.  I don't think he can force a particular order
(and if he could, there'd be little need for the per-page counts
anyway).  I suppose he could hold all the updates in a temp table
and apply them in a sorted order at end of transaction, but that seems
like a pain.

I would suggest using a separate transaction for each webpage visited.
Holding a transaction open across multiple page traversals is widely
considered bad news for a number of reasons, not only this one.

			regards, tom lane



view thread (9+ messages)  latest in thread

Message-ID: <15369.1043094012@sss.pgh.pa.us>
Permalink:  ../15369.1043094012@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15369.1043094012@sss.pgh.pa.us

 · 

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-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ron@intervideo.com, bhuvansql@myrealbox.com
  Subject: Re: deadlock problem in Ad serving..
  In-Reply-To: <15369.1043094012@sss.pgh.pa.us>
  References: <Pine.LNX.4.33.0301200949540.13721-100000@ron> <15369.1043094012@sss.pgh.pa.us>

* 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