Clearing locks

--001636eee59a6d387a048875c09e
Content-Type: text/plain; charset=ISO-8859-1

I'm on PostgreSQL 8.3.11 on Debian.

I have a small piece of DDL (alter table title drop column is_target) that
hangs "waiting" forever. (I've waited hours - it still shows as waiting in
pg_top.) I have restarted the database - even tried it in single-user mode
- but it still waits.

When I execute a query to get lock info:

select
pg_class.relname,pg_locks.locktype,mode,virtualtransaction,d atabase,relation,granted
from pg_class,pg_locks where pg_class.relfilenode=pg_locks.relation;

(These are all the columns in pg_locks with anything but null in them.)

relname | locktype | mode |
virtualtransaction | database | relation | granted
--------------------------------------+----------+---------- -------+--------------------+----------+----------+---------
property_key_name_index | relation | AccessShareLock |
-1/22805859 | 64197 | 361377 | t
location_network_name_index | relation | AccessShareLock |
-1/22805859 | 64197 | 925488 | t
serial_item_ref_num_idx | relation | AccessShareLock |
-1/22805859 | 64197 | 78445 | t
course_locator_id_key | relation | AccessShareLock |
-1/22805859 | 64197 | 139543 | t
pg_class_oid_index | relation | AccessShareLock |
2/35 | 64197 | 2662 | t
transit_locator_source_id_index | relation | AccessShareLock |
-1/22805859 | 64197 | 71026 | t
transit_locator_destination_id_index | relation | AccessShareLock |
-1/22805859 | 64197 | 71025 | t
pg_locks | relation | AccessShareLock |
2/35 | 64197 | 10969 | t
pg_class_relname_nsp_index | relation | AccessShareLock |
2/35 | 64197 | 2663 | t
course_locator_location_id | relation | AccessShareLock |
-1/22805859 | 64197 | 139707 | t
property_key_category_ordering_index | relation | AccessShareLock |
-1/22805859 | 64197 | 361381 | t
serial_item_condition | relation | AccessShareLock |
-1/22805859 | 64197 | 139711 | t
user_account_customer_id | relation | AccessShareLock |
-1/22805859 | 64197 | 404180 | t
customer_locator_unique_index | relation | AccessShareLock |
-1/22805859 | 64197 | 361408 | t
web_store_store_id | relation | AccessShareLock |
-1/22805859 | 64197 | 404179 | t
custom_title | relation | AccessShareLock |
-1/22805859 | 64197 | 64244 | t
store | relation | AccessShareLock |
-1/22805859 | 64197 | 64588 | t
store_pkey | relation | AccessShareLock |
-1/22805859 | 64197 | 70822 | t
custom_title_pkey | relation | AccessShareLock |
-1/22805859 | 64197 | 70702 | t
title_product_code_like_index | relation | AccessShareLock |
-1/22805859 | 64197 | 355673 | t
title_desc_author_fulltext_index | relation | AccessShareLock |
-1/22805859 | 64197 | 357244 | t
property_value_key_location_index | relation | AccessShareLock |
-1/22805859 | 64197 | 361407 | t
web_store_store_name_index | relation | AccessShareLock |
-1/22805859 | 64197 | 92414 | t
custom_title_location_id_index | relation | AccessShareLock |
-1/22805859 | 64197 | 70916 | t
course_locator_division_id_key | relation | AccessShareLock |
-1/22805859 | 64197 | 139892 | t
property_key_lookup_name_index | relation | AccessShareLock |
-1/22805859 | 64197 | 404257 | t
pg_class | relation | AccessShareLock |
2/35 | 64197 | 1259 | t
web_store | relation | AccessShareLock |
-1/22805859 | 64197 | 92411 | t
user_account_username_index | relation | AccessShareLock |
-1/22805859 | 64197 | 925492 | t
transit_locator | relation | AccessShareLock |
-1/22805859 | 64197 | 64392 | t
inventory_item_locator_id | relation | AccessShareLock |
-1/22805859 | 64197 | 925487 | t
inventory_item_sku_index | relation | AccessShareLock |
-1/22805859 | 64197 | 925490 | t
transit_locator_pkey | relation | AccessShareLock |
-1/22805859 | 64197 | 70858 | t
(33 rows)


I'm not seeing anything there with exclusives, but there are several indexes
listed here from that table under the -1/22805859 virtual transaction.

I seem to be able to execute DDL modifications on other tables without
indexes in this list without issues.

Do I need to clear these locks to get this to run? If so, how? WIth the
exception of the 2/35 transactions, they don't belong to a process - and
those belong to the process running the query that lists the locks :-)

It also appears that I can't execute a "drop index" on that table either.
Thoughts? How do I fix this so I can run DDL?

Please let me know what further information I can provide.

Thanks!

Matt

Matthew Excell

--001636eee59a6d387a048875c09e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I'm on PostgreSQL 8.3.11 on Debian.<br><br>I have a small piece of DDL =
(alter table title drop column is_target) that hangs "waiting" fo=
rever. (I've waited hours - it still shows as waiting in pg_top.)=A0 I =
have restarted the database - even tried it in single-user mode - but it st=
ill waits.<br>

<br>When I execute a query to get lock info: <br><br>select pg_class.relnam=
e,pg_locks.locktype,mode,virtualtransaction,database,relatio n,granted from =
pg_class,pg_locks where pg_class.relfilenode=3Dpg_locks.relation;<br><br>

(These are all the columns in pg_locks with anything but null in them.)<br>=
<br><font face=3D"courier new,monospace">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0 relname=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | locktype |=
=A0=A0=A0=A0=A0 mode=A0=A0=A0=A0=A0=A0 | virtualtransaction | database | re=
lation | granted <br>

--------------------------------------+----------+---------- -------+-------=
-------------+----------+----------+---------<br>=A0property_key_name_index=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | -1/2=
2805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 361377 | t<br>

=A0location_network_name_index=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | Acce=
ssShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 925=
488 | t<br> =A0serial_item_ref_num_idx=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= A0=
=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=
=A0 64197 |=A0=A0=A0 78445 | t<br>

=A0course_locator_id_key=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0 | rel=
ation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197=
|=A0=A0 139543 | t<br>=A0pg_class_oid_index=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | 2/35=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0=A0 2662 | t<br>

=A0transit_locator_source_id_index=A0=A0=A0=A0=A0 | relation | AccessShareL=
ock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 71026 | =
t<br>=A0transit_locator_destination_id_index | relation | AccessShareLock |=
-1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 71025 | t<br>

=A0pg_locks=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | 2/35=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 10969 | t<br>=A0pg_cla=
ss_relname_nsp_index=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | AccessShare=
Lock | 2/35=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=
=A0=A0=A0 2663 | t<br>

=A0course_locator_location_id=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | Ac=
cessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 1=
39707 | t<br>=A0property_key_category_ordering_index | relation | AccessSha=
reLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 361381 |=
t<br>

=A0serial_item_condition=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0 | rel=
ation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197=
|=A0=A0 139711 | t<br>=A0user_account_customer_id=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=
=A0 |=A0=A0=A0 64197 |=A0=A0 404180 | t<br>

=A0customer_locator_unique_index=A0=A0=A0=A0=A0=A0=A0 | relation | AccessSh=
areLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 361408 =
| t<br> =A0web_store_store_id=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=
=A0=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=
=A0=A0=A0 64197 |=A0=A0 404179 | t<br>

=A0custom_title=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=
=A0=A0=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=
=A0 |=A0=A0=A0 64197 |=A0=A0=A0 64244 | t<br>=A0store=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0 | =
relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64=
197 |=A0=A0=A0 64588 | t<br>

=A0store_pkey=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A 0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=
=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 70822 | t<br>=A0custom_title_pkey=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | AccessS=
hareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 707=
02 | t<br>

=A0title_product_code_like_index=A0=A0=A0=A0=A0=A0=A0 | relation | AccessSh=
areLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 355673 =
| t<br>=A0title_desc_author_fulltext_index=A0=A0=A0=A0 | relation | AccessS=
hareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 357244=
| t<br>

=A0property_value_key_location_index=A0=A0=A0 | relation | AccessShareLock =
| -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 361407 | t<br>=
=A0web_store_store_name_index=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | Ac=
cessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=
=A0 92414 | t<br>

=A0custom_title_location_id_index=A0=A0=A0=A0=A0=A0 | relation | AccessShar=
eLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 70916 =
| t<br>=A0course_locator_division_id_key=A0=A0=A0=A0=A0=A0 | relation | Acc=
essShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 13=
9892 | t<br>

=A0property_key_lookup_name_index=A0=A0=A0=A0=A0=A0 | relation | AccessShar=
eLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 404257 | =
t<br> =A0pg_class=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | 2/35=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0=A0 1259 | t<br>

=A0web_store=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=
=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 92411 | t<br>=A0user_account_username=
_index=A0=A0=A0=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | -1/2280585=
9=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 925492 | t<br>

=A0transit_locator=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=
=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=
=A0=A0 64197 |=A0=A0=A0 64392 | t<br>=A0inventory_item_locator_id=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=
=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=A0 925487 | t<br>

=A0inventory_item_sku_index=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 | relation =
| AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=A0=A0 |=A0=A0=A0 64197 |=A0=
=A0 925490 | t<br>=A0transit_locator_pkey=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0 | relation | AccessShareLock | -1/22805859=A0=A0=A0=A0=A0=
=A0=A0 |=A0=A0=A0 64197 |=A0=A0=A0 70858 | t<br>

(33 rows)<br><br><br></font><font face=3D"arial,helvetica,sans-serif">I'=
;m not seeing anything there with exclusives, but there are several indexes=
listed here from that table under the -1/22805859 virtual transaction.</fo=
nt><br>

<br>I seem to be able to execute DDL modifications on other tables without =
indexes in this list without issues.<br><br>Do I need to clear these locks =
to get this to run? If so, how? WIth the exception of the 2/35 transactions=
, they don't belong to a process - and those belong to the process runn=
ing the query that lists the locks :-)<br>

<br>It also appears that I can't execute a "drop index" on th=
at table either.=A0 Thoughts? How do I fix this so I can run DDL?<br><br>Pl=
ease let me know what further information I can provide. <br><br>Thanks!<br=
>

<br>Matt<br><br>Matthew Excell<br><br>

--001636eee59a6d387a048875c09e--
Matthew Excell [ Mo, 07 Juni 2010 21:33 ] [ ID #2042760 ]

Re: Clearing locks

Excerpts from Matthew Excell's message of lun jun 07 15:33:27 -0400 2010:
> I'm on PostgreSQL 8.3.11 on Debian.
>
> I have a small piece of DDL (alter table title drop column is_target) t=
hat
> hangs "waiting" forever. (I've waited hours - it still shows as waiting=
in
> pg_top.) I have restarted the database - even tried it in single-user =
mode
> - but it still waits.
>
> When I execute a query to get lock info:
>
> select
> pg_class.relname,pg_locks.locktype,mode,virtualtransaction,d atabase,rel=
ation,granted
> from pg_class,pg_locks where pg_class.relfilenode=3Dpg_locks.relation;
>
> (These are all the columns in pg_locks with anything but null in them.)
>
> relname | locktype | mode |
> virtualtransaction | database | relation | granted
> --------------------------------------+----------+---------- -------+---=
-----------------+----------+----------+---------
> property_key_name_index | relation | AccessShareLock |
> -1/22805859 | 64197 | 361377 | t

uh. Check pg_prepared_transactions (or was it pg_prepared_xacts?) and
do a ROLLBACK PREPARED (or COMMIT PREPARED) if there's anything that
shouldn't be there.

--
=C3=81lvaro Herrera <alvherre [at] commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
alvherre [ Mo, 07 Juni 2010 21:46 ] [ ID #2042761 ]

Re: Clearing locks

--002215048dfb89f1cd0488761c33
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

That did it. Thanks!

Matthew Excell


On Mon, Jun 7, 2010 at 1:46 PM, Alvaro Herrera
<alvherre [at] commandprompt.com>wrote:

> Excerpts from Matthew Excell's message of lun jun 07 15:33:27 -0400 2010:
> > I'm on PostgreSQL 8.3.11 on Debian.
> >
> > I have a small piece of DDL (alter table title drop column is_target)
> that
> > hangs "waiting" forever. (I've waited hours - it still shows as waiting
> in
> > pg_top.) I have restarted the database - even tried it in single-user
> mode
> > - but it still waits.
> >
> > When I execute a query to get lock info:
> >
> > select
> >
> pg_class.relname,pg_locks.locktype,mode,virtualtransaction,d atabase,relat=
ion,granted
> > from pg_class,pg_locks where pg_class.relfilenode=3Dpg_locks.relation;
> >
> > (These are all the columns in pg_locks with anything but null in them.)
> >
> > relname | locktype | mode |
> > virtualtransaction | database | relation | granted
> >
> --------------------------------------+----------+---------- -------+-----=
---------------+----------+----------+---------
> > property_key_name_index | relation | AccessShareLock |
> > -1/22805859 | 64197 | 361377 | t
>
> uh. Check pg_prepared_transactions (or was it pg_prepared_xacts?) and
> do a ROLLBACK PREPARED (or COMMIT PREPARED) if there's anything that
> shouldn't be there.
>
> --
> =C1lvaro Herrera <alvherre [at] commandprompt.com>
> The PostgreSQL Company - Command Prompt, Inc.
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>

--002215048dfb89f1cd0488761c33
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

That did it. Thanks!<br><br clear=3D"all">Matthew Excell<br>
<br><br><div class=3D"gmail_quote">On Mon, Jun 7, 2010 at 1:46 PM, Alvaro H=
errera <span dir=3D"ltr"><<a href=3D"mailto:alvherre [at] commandprompt.com">=
alvherre [at] commandprompt.com</a>></span> wrote:<br><blockquote class=3D"gm=
ail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt =
0pt 0pt 0.8ex; padding-left: 1ex;">

Excerpts from Matthew Excell's message of lun jun 07 15:33:27 -0400 201=
0:<br>
<div class=3D"im">> I'm on PostgreSQL 8.3.11 on Debian.<br>
><br>
> I have a small piece of DDL (alter table title drop column is_target) =
that<br>
> hangs "waiting" forever. (I've waited hours - it still s=
hows as waiting in<br>
> pg_top.) =A0I have restarted the database - even tried it in single-us=
er mode<br>
> - but it still waits.<br>
><br>
> When I execute a query to get lock info:<br>
><br>
> select<br>
> pg_class.relname,pg_locks.locktype,mode,virtualtransaction,d atabase,re=
lation,granted<br>
> from pg_class,pg_locks where pg_class.relfilenode=3Dpg_locks.relation;=
<br>
><br>
> (These are all the columns in pg_locks with anything but null in them.=
)<br>
><br>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0relname =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
| locktype | =A0 =A0 =A0mode =A0 =A0 =A0 |<br>
> virtualtransaction | database | relation | granted<br>
> --------------------------------------+----------+---------- -------+--=
------------------+----------+----------+---------<br>
> =A0property_key_name_index =A0 =A0 =A0 =A0 =A0 =A0 =A0| relation | Acc=
essShareLock |<br>
> -1/22805859 =A0 =A0 =A0 =A0| =A0 =A064197 | =A0 361377 | t<br>
<br>
</div>uh. =A0Check pg_prepared_transactions (or was it pg_prepared_xacts?) =
and<br>
do a ROLLBACK PREPARED (or COMMIT PREPARED) if there's anything that<br=
>
shouldn't be there.<br>
<font color=3D"#888888"><br>
--<br>
=C1lvaro Herrera <<a href=3D"mailto:alvherre [at] commandprompt.com">alvherre=
[at] commandprompt.com</a>><br>
The PostgreSQL Company - Command Prompt, Inc.<br>
PostgreSQL Replication, Consulting, Custom Development, 24x7 support<br>
</font></blockquote></div><br>

--002215048dfb89f1cd0488761c33--
Matthew Excell [ Mo, 07 Juni 2010 21:59 ] [ ID #2042762 ]
Datenbanken » gmane.comp.db.postgresql.admin » Clearing locks

Vorheriges Thema: PITR Recovery Question
Nächstes Thema: restore db from other db folder