Postgres wont drop foriegn keys on tables.

Started by Chris Barnesover 15 years ago4 messagesgeneral
Jump to latest
#1Chris Barnes
compuguruchrisbarnes@hotmail.com

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

#2Chris Barnes
compuguruchrisbarnes@hotmail.com
In reply to: Chris Barnes (#1)
Re: Postgres wont drop foriegn keys on tables.

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

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

#3Vick Khera
vivek@khera.org
In reply to: Chris Barnes (#1)
Re: Postgres wont drop foriegn keys on tables.

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.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Chris Barnes (#1)
Re: Postgres wont drop foriegn keys on tables.

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