pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vadim Mikheev <vadim@krs.ru>
To: Oleg Bartunov <oleg@sai.msu.su>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgreSQL.org
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] inserts/updates problem under stressing !
Date: Mon, 26 Jul 1999 14:26:06 +0800
Message-ID: <379BFF7E.BD57269E@krs.ru> (raw)
References: <Pine.GSO.3.96.SK.990726100222.10884A-100000@ra>

Oleg Bartunov wrote:
> 
> >
> > SELECT FOR UPDATE will not help: if there was no record for
> > particular key then nothing will be locked and two records with
> > the same key will be inserted.
> >
> > Oleg, use LOCK IN SHARE ROW EXCLUSIVE MODE.
> 
> Thanks Vadim. Just tried this, but still I see a difference between
> count hits (accumulated) from db and access_log. In my test these numbers are:
> 95 and 109. So I lost 14 hits ! And no errors !
> In my handler I have now:
> 
> my $sth = $dbh->do("LOCK TABLE hits IN SHARE ROW EXCLUSIVE MODE");
> my $sth = $dbh->do("SELECT acc_hits($1)") || die $dbh->errstr;
> 
> am I right ?

You should run LOCK and SELECT inside BEGIN/END (i.e. in
the same transaction), do you?

Vadim



view thread (11+ messages)  latest in thread

Message-ID: <379BFF7E.BD57269E@krs.ru>
Permalink:  ../379BFF7E.BD57269E@krs.ru/
Also on:    postgresql.org/message-id/379BFF7E.BD57269E@krs.ru

 · 

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-sql@postgresql.org
  Cc: vadim@krs.ru, oleg@sai.msu.su, tgl@sss.pgh.pa.us, pgsql-hackers@postgreSQL.org
  Subject: Re: [SQL] inserts/updates problem under stressing !
  In-Reply-To: <379BFF7E.BD57269E@krs.ru>
  References: <Pine.GSO.3.96.SK.990726100222.10884A-100000@ra> <379BFF7E.BD57269E@krs.ru>

* 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