Re: Problem dropping a table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dan Armbrust <daniel(dot)armbrust(dot)list(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem dropping a table
Date: 2006-05-09 15:45:49
Message-ID: 12098.1147189549@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dan Armbrust <daniel(dot)armbrust(dot)list(at)gmail(dot)com> writes:
> I have a java application that is trying to dynamically drop a set of
> tables. Problem is, when it gets to a particular table and I execute
> the "drop table foo cascade" command from a prepared statement, the
> query never returns. It just hangs indefinitely. I presume that it is
> waiting on a lock for this table, but there is nothing that I know of
> that should be locking this table.

> So, I have two issues - the first, how do I prevent myself from hanging
> indefinitely? I tried 'setQueryTimeout' on the prepared statement, but
> it doesn't seem to have any effect. Still hangs indefinitely.

You should complain to the JDBC list about that. The underlying backend
facility works as expected:

session 1:

regression=# create table foo (f int);
CREATE TABLE
regression=# begin;
BEGIN
regression=# lock table foo;
LOCK TABLE

session 2:

regression=# set statement_timeout TO 1000;
SET
regression=# drop table foo cascade;
... after a second ...
ERROR: canceling statement due to statement timeout
regression=#

> The second, how can I track down what is locking this table?

Look in pg_locks to start with.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message beer 2006-05-09 15:46:17 Encoding Conversion
Previous Message Dan Armbrust 2006-05-09 15:39:30 Problem dropping a table