Patch: show relation and tuple infos of a lock to acquire - Mailing list pgsql-hackers

From Christian Kruse
Subject Patch: show relation and tuple infos of a lock to acquire
Date
Msg-id 20131231091244.GB25649@defunct.ch
Whole thread Raw
Responses Re: Patch: show relation and tuple infos of a lock to acquire
Re: Patch: show relation and tuple infos of a lock to acquire
List pgsql-hackers
Hi there,

I created a patch improving the log_lock_wait messages by adding
relation infos (name and OID) as well as tuple infos (if present –
ctid and, if available, the tuple itself) in the context.

Sample output (log_lock_waits=on required):

session 1:
CREATE TABLE foo (val integer);
INSERT INTO foo (val) VALUES (1);
BEGIN;
UPDATE foo SET val = 3;

session 2:
BEGIN;
UPDATE TABLE foo SET val = 2;

Output w/o patch:

LOG:  process 24774 acquired ShareLock on transaction 696 after 11688.720 ms

Output with patch:

LOG:  process 24774 acquired ShareLock on transaction 696 after 11688.720 ms
CONTEXT:  relation name: foo (OID 16385)
        tuple (ctid (0,1)): (1)

I am not really sure where to put the functions. Currently they are
located in backend/storage/lmgr/lmgr.c because XactLockTableWait() is
located there, too. What do you think?

I also created a test spec for easy creation of the log output;
however, I was not able to provide an expected file since the process
IDs vary from test run to test run.

Regards,

--
 Christian Kruse               http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE
Next
From: Christian Kruse
Date:
Subject: Re: Patch: Show process IDs of processes holding a lock; show relation and tuple infos of a lock to acquire