Need help understanding pg_locks

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Need help understanding pg_locks
Date: 2011-07-10 04:01:19
Message-ID: 201107100401.p6A41JR02682@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Can someone help me understand pg_locks? There are three fields related
to virtual and real xids:

virtualtransaction | text |
transactionid | xid |
virtualxid | text |

Our docs say 'virtualtransaction' is:

Virtual ID of the transaction that is holding or awaiting this lock

This field was clear to me.

and 'transactionid' is documented as:

ID of a transaction, or null if the object is not a transaction ID

In my testing it was the (non-virtual) xid of the lock holder. Is that
correct? Can it be a waiter?

'virtualxid' is documented as:

Virtual ID of a transaction, or null if the object is not a
virtual transaction ID

In my testing this field is for locking your own vxid, meaning it owned
by its own vxid.

I looked at the C code in /pg/backend/utils/adt/lockfuncs.c and was
confused.

Clearly our documentation is lacking in this area and I would like to
clarify it.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2011-07-10 04:36:47 Re: Extra check in 9.0 exclusion constraint unintended consequences
Previous Message Alvaro Herrera 2011-07-10 03:49:28 Re: per-column generic option