Thread: Postgres wont drop foriegn keys on tables.

Postgres wont drop foriegn keys on tables.

From
Chris Barnes
Date:
I am having an odd problem that I have seen before. It usually clears itself after I restart postgres.

I am attempting to drop an foreign key on a table and it sits for hours and doesn't drop or put anything into the log.

Killing the alter puts an error in, but it doesn't time out and it cause the system to lock at some point.

What can I do to troubleshoot this?

Chris


Re: Postgres wont drop foriegn keys on tables.

From
Chris Barnes
Date:
Sorry,

I am running the following.

[postgres@pgprd01 pgcheck]$ psql --version
psql (PostgreSQL) 8.4.2
contains support for command-line editing

[postgres@pgprd01 pgcheck]$ uname -a
Linux system.name.com 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux





From: compuguruchrisbarnes@hotmail.com
To: pgsql-general@postgresql.org
Subject: [GENERAL] Postgres wont drop foriegn keys on tables.
Date: Thu, 23 Sep 2010 11:01:28 -0400

.ExternalClass .ecxhmmessage P {padding:0px;} .ExternalClass body.ecxhmmessage {font-size:10pt;font-family:Tahoma;} I am having an odd problem that I have seen before. It usually clears itself after I restart postgres.

I am attempting to drop an foreign key on a table and it sits for hours and doesn't drop or put anything into the log.

Killing the alter puts an error in, but it doesn't time out and it cause the system to lock at some point.

What can I do to troubleshoot this?

Chris


Re: Postgres wont drop foriegn keys on tables.

From
Vick Khera
Date:
On Thu, Sep 23, 2010 at 11:01 AM, Chris Barnes
<compuguruchrisbarnes@hotmail.com> wrote:
> I am attempting to drop an foreign key on a table and it sits for hours and
> doesn't drop or put anything into the log.
>

Does the pg_stat_activity view show that it is waiting for a lock?  It
will need to lock both the origin and destination tables of the FK to
clear the triggers.

Re: Postgres wont drop foriegn keys on tables.

From
Tom Lane
Date:
Chris Barnes <compuguruchrisbarnes@hotmail.com> writes:
> I am attempting to drop an foreign key on a table and it sits for hours and doesn't drop or put anything into the
log.

Dropping a foreign key is fast in itself, but it requires exclusive lock
on both the referencing and referenced tables.  Look to see what is
blocking the lock request.  pg_locks and pg_stat_activity views are
your friends.

            regards, tom lane