Re: how to release a transaction lock on a table?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Si Chen <schen(at)graciousstyle(dot)com>
Cc: PgSql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: how to release a transaction lock on a table?
Date: 2005-01-31 19:30:43
Message-ID: 20050131193043.GA50502@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 31, 2005 at 10:13:26AM -0800, Si Chen wrote:

> Hello everyone. I am trying to do an ALTER TABLE, but it hangs
> indefinitely. I think the table is locked from a transaction, and in
> pg_locks I found:
> relation 75907
> database 74861
> pid 29604
> mode AccessExclusiveLock
> granted f

Look for other processes that have a lock on the table:

SELECT * FROM pg_locks WHERE relation = 75907;

If you have stats_command_string turned on then you can query
pg_stat_activity to see what the other processes are doing.

> Is there a way to release this lock? Or does the database need to
> re-started?

Before taking drastic steps like restarting the database, find out
who holds the conflicting lock and why. You might have an application
sitting idle in a transaction that it should be committing or rolling
back, in which case the application should probably be fixed.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2005-01-31 19:40:57 Re: Mail list / web issues
Previous Message Tom Lane 2005-01-31 19:08:26 Re: Dereferencing a 2-dimensional array in plpgsql