Re: how to find transaction associated with a lock

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: schen(at)graciousstyle(dot)com
Cc: pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: Re: how to find transaction associated with a lock
Date: 2004-07-22 20:45:03
Message-ID: 12341.1090529103@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general pgsql-novice

Si Chen <schen(at)graciousstyle(dot)com> writes:
> Does anyone know of a way to go from transactions identifiers to the
> actual transaction--which tables, which statements, etc. etc.?

See pg_stat_activity.

The pg_locks entries you are looking at do *not* represent table locks
of any kind. This:
> NULL NULL 3366868 27149 ExclusiveLock TRUE
simply says that transaction 3366868 is still running. This:
> NULL NULL 3366868 1069 ShareLock FALSE
says that process 1069 has elected to wait until transaction 3366868
finishes. Normally the reason for doing that would be that transaction
3366868 holds a row lock (SELECT FOR UPDATE lock) on some row that
process 1069's transaction wants to acquire row lock on.

However, I suspect what you are really wishing is to find out the
individual row that is being contended for, and there is not enough
information in the system views to do that (mainly because we do not
keep per-row locking information in shared memory).

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Si Chen 2004-07-22 21:44:29 Re: [ADMIN] how to find transaction associated with a lock
Previous Message Tom Lane 2004-07-22 20:19:53 Re: [HACKERS] Point in Time Recovery

Browse pgsql-general by date

  From Date Subject
Next Message Si Chen 2004-07-22 21:44:29 Re: [ADMIN] how to find transaction associated with a lock
Previous Message Si Chen 2004-07-22 19:16:38 how to find transaction associated with a lock

Browse pgsql-novice by date

  From Date Subject
Next Message Si Chen 2004-07-22 21:44:29 Re: [ADMIN] how to find transaction associated with a lock
Previous Message Si Chen 2004-07-22 19:16:38 how to find transaction associated with a lock