pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rainer Frey <rainer.frey@inxmail.de>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #1459: Connection hangs when other connection is not
Date: Fri, 04 Feb 2005 11:54:56 +0100
Message-ID: <42035480.2060707@inxmail.de> (raw)
In-Reply-To: <200502041054.16723.peter_e@gmx.net>
References: <20050203151126.467DC9A5818@www.postgresql.com>
	<200502041054.16723.peter_e@gmx.net>

Peter Eisentraut schrieb:
> Am Donnerstag, 3. Februar 2005 16:11 schrieb Rainer Frey:
> 
>>A select should not lock a table even when it is not committed.
> 
> 
> The SELECT obtains a read (shared) lock on the table, but the ALTER TABLE 
> requires a write (exclusive) lock.  This is certainly necessary because you 
> don't want the structure of the table to be changed while you are reading it.  
> Additionally, the locking protocol requires that all locks once obtained need 
> to be held until the end of the transaction.  Both of these issues together 
> explain the problem you are seeing.  There is nothing that can be done about 
> it.

Thanks for the explanation, though I don't really get the necessity of a 
commit for a read-only statement. Can't a SELECT release its lock after 
it received the response?
Is there any possibility to set a timeout for the lock, after which the 
ALTER TABLE statement fails, instead of remaining in wait status (when 
calling with JDBC?

Rainer Frey



view thread (6+ messages)  latest in thread

Message-ID: <42035480.2060707@inxmail.de>
Permalink:  ../42035480.2060707@inxmail.de/
Also on:    postgresql.org/message-id/42035480.2060707@inxmail.de

 · 

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-jdbc@postgresql.org
  Cc: rainer.frey@inxmail.de, peter_e@gmx.net, pgsql-bugs@postgresql.org
  Subject: Re: BUG #1459: Connection hangs when other connection is not
  In-Reply-To: <42035480.2060707@inxmail.de>
  References: <20050203151126.467DC9A5818@www.postgresql.com> <200502041054.16723.peter_e@gmx.net> <42035480.2060707@inxmail.de>

* 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