Re: concurrent updates problem

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: <mwaples(at)waples(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: concurrent updates problem
Date: 2001-03-19 09:54:12
Message-ID: 005b01c0b05a$8e6b0f20$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: <mwaples(at)waples(dot)net>

> I have on a web application
> update threads set views = views + 1 where forum_id = 1 and thread_id =
> 1
> just to record view for that page - stupid I know but people want it.
> Problem comes when I use apache's ab to test it.
>
> It just doesnt produce the correct result with 10 or so concurrent
> connections. The views ends up being completely out.(no failed queries)

So the views total is less than you'd expect.

> I read up on transaction Isolations , using select for update etc
> but can't get it to work correctly - I thought serilizable might do the
> trick but only few queries were rolled back -
> Can anyone point me in the right direction to solve this ?

Can't think what difference it should make how many connections you have.
The update you show will take place in its own transaction so should always
be consistent. The query should block if it needs to wait on another process
updating.

I can only think that you might not be checking for success/failure at some
point in the code. If you can boil it down to a small Perl/PHP script I can
try and duplicate it here - if not, post the relevant code and we'll see if
more eyeballs can't spot something.

- Richard Huxton

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavin Sherry 2001-03-19 10:02:25 Re: concurrent updates problem
Previous Message juerg.rietmann 2001-03-19 09:07:26 postgreSQL db temporary on Microsoft IIS 4.0