Re: BUG #11321: describe command is getting locked due to ALTER statement running on public table

Lists: Postg토토SQL : Postg토토SQL 메일 링리스트 : 2014-09-01 이후 PGSQL-BUGS 17:01
From: adurugkar(at)xento(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #11321: describe command is getting locked due to ALTER statement running on public table
Date: 2014-09-01 11:55:37
Message-ID: 20140901115537.2921.56171@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 11321
Logged by: Ashutosh Durugkar
Email address: adurugkar(at)xento(dot)com
PostgreSQL version: 9.3.5
Operating system: Ubuntu 12.04
Description:

Hello Experts,

I found this bug in postgresql-9.3.5 version-

describe command is getting locked due to ALTER statement running on real
table.

How to reproduce-

Session 1-

create table test (t int, name varchar(10));
alter table test add constraint uk_id UNIQUE (t);
BEGIN;
alter table test DROP constraint uk_id ;

Session 2-

BEGIN;

\d test --This command goes into waiting state.

postgres=# select query from pg_stat_activity where waiting='t';
query
--------------------------------------------------------------------------------------------------------------------------------------
SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered,
i.indisvalid, pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),+
pg_catalog.pg_get_constraintdef(con.oid, true), contype, condeferrable,
condeferred, c2.reltablespace +
FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i
+
LEFT JOIN pg_catalog.pg_constraint con ON (conrelid = i.indrelid AND
conindid = i.indexrelid AND contype IN ('p','u','x')) +
WHERE c.oid = '2309188489' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
+
ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname;

It was working fine on 9.3.4 version.

Thanks for looking.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: adurugkar(at)xento(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #11321: describe command is getting locked due to ALTER statement running on public table
Date: 2014-09-01 17:01:54
Message-ID: 11249.1409590914@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg토토SQL : Postg토토SQL 메일 링리스트 : 2014-09-01 이후 PGSQL-BUGS 17:01

adurugkar(at)xento(dot)com writes:
> describe command is getting locked due to ALTER statement running on real
> table.

This isn't a bug IMO; if anything, it's a bug that the old implementation
of pg_get_indexdef didn't result in acquiring any lock. Without a lock,
you're at least at risk of printing garbage information, and I suspect
crashes were not out of the question.

> It was working fine on 9.3.4 version.

I rather doubt this behavior changed just in 9.3.5. That code got
rewritten during 9.3 development.

regards, tom lane