From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joseph Shraibman <jks@selectacast.net>
Cc: pgsql-general@hub.org <pgsql-general@hub.org>
Subject: Re: select for update not locking properly.
Date: Thu, 13 Jul 2000 03:34:20 -0400
Message-ID: <28676.963473660@sss.pgh.pa.us> (raw)
In-Reply-To: <396D2AEA.5D19984A@selectacast.net>
References: <396D2AEA.5D19984A@selectacast.net>
Joseph Shraibman <jks@selectacast.net> writes:
> But the locking isn't working properly. I do something that should
> cause 3 different threads to try and do that append, and the first one
> goes through properly, but the second two append to the result of the
> first on only, meaning that the third one didn't see the result of the
> second's append.
Can't duplicate it here. I did:
<in psql window 1>
regression=# create table mytable(mystring text, x int, y int);
CREATE
regression=# insert into mytable values('z',1,4);
INSERT 399867 1
regression=# insert into mytable values('foo',3,4);
INSERT 399868 1
regression=# begin;
BEGIN
regression=# SELECT mystring FROM mytable WHERE x = 3 AND y = 4 FOR UPDATE;
mystring
----------
foo
(1 row)
<in psql window 2>
regression=# begin;
BEGIN
regression=# SELECT mystring FROM mytable WHERE x = 3 AND y = 4 FOR UPDATE;
[ psql hangs ]
<in psql window 3>
regression=# begin;
BEGIN
regression=# SELECT mystring FROM mytable WHERE x = 3 AND y = 4 FOR UPDATE;
[ psql hangs ]
<back to psql window 1>
regression=# UPDATE mytable SET mystring = 'foo bar' WHERE x = 3 AND y = 4;
UPDATE 1
regression=# end;
COMMIT
regression=#
<psql window 3 now responds>
mystring
----------
foo bar
(1 row)
regression=# UPDATE mytable SET mystring = 'foo bar baz' WHERE x = 3 AND y = 4;
UPDATE 1
regression=# end;
COMMIT
regression=#
<psql window 2 now responds>
mystring
-------------
foo bar baz
(1 row)
regression=#
Looks pretty cool to me...
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, jks@selectacast.net, pgsql-general@hub.org
Subject: Re: select for update not locking properly.
In-Reply-To: <28676.963473660@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