Skip site navigation (1) Skip section navigation (2)

Re: Problem with SELECT FOR UPDATE NOWAIT

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: Mathias Laurent <e1lauren(at)hotmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Problem with SELECT FOR UPDATE NOWAIT
Date: 2006-04-20 22:47:38
Message-ID: 20060420224737.GP49405@pervasive.com (view raw or flat)
Thread:
Lists: pgsql-admin
I think you're confused about what actually happened...

Session 1:
decibel=# select * from a;
 i 
---
 1
(1 row)

decibel=# begin;
BEGIN
decibel=# select * from a for update nowait;
 i 
---
 1
(1 row)

decibel=# 

Session 2:
decibel=# select * from a for update nowait;
ERROR:  could not obtain lock on row in relation "a"
decibel=# select * from a for update;

...waits...

Session 1:
decibel=# rollback;
ROLLBACK
decibel=# 

And immediately in session 2:
 i 
---
 1
(1 row)

decibel=# 

On Thu, Apr 13, 2006 at 01:57:47AM +0000, Mathias Laurent wrote:
> Hello,
> 
> Veiled I have a small problem which I have solved in a way not very clean, 
> I would thus like to have your opinion. When I made with the process 1 :
> 
> Select * FROM myTable WHERE num=3 FOR UPDATE NOWAIT
> 
> And that I remade it with a process 2 before having do one "Commit" It 
> blocked me (until there normal)
> But once that I free by doing one "Commit" with process 1 All the table 
> remains to block for process 2...
> To have access it, it is necessary that I do one "Commit" with the 
> processus2 !! It's very strange...
> 
> Thank you,
> 
> Mathias Laurent
> 
> _________________________________________________________________
> Windows Live Mail : d?couvrez et testez la version b?ta ! 
> http://www.ideas.live.com/
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
> 
>               http://www.postgresql.org/docs/faq
> 

-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby(at)pervasive(dot)com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

In response to

pgsql-admin by date

Next:From: Jim C. NasbyDate: 2006-04-21 01:31:22
Subject: Re: what the problem with this query
Previous:From: Jim C. NasbyDate: 2006-04-20 22:43:17
Subject: Re: WAL file naming after postmaster restart

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group