Re: Let's invent a function to report lock-wait-blocking PIDs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Let's invent a function to report lock-wait-blocking PIDs
Date: 2013-03-22 14:24:30
Message-ID: 4434.1363962270@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> writes:
> On 21.03.2013 05:36, Tom Lane wrote:
>>> The API that comes to mind is (name subject to bikeshedding)
>>> pg_blocking_pids(pid int) returns int[]

> How about inverting the function into:
> pg_pid_blocked_by(pid int) returns int
> It would take as argument a pid, and return the pid of the process that
> is blocking the given process. That would feel more natural to me.

Hm, I'm not sure that's uniquely defined. In the case I mentioned
before (A has AccessShare, B is blocked waiting for AccessExclusive,
C wants AccessShare and is queued behind B), which of A and B do
you think is blocking C?

Whichever answer you choose could be the wrong one for isolationtester:
I think it needs to consider that C is blocked if *either* A or B is
part of its set of test processes. So that's why I thought an array
(or set) result including both A and B would be appropriate. AFAICT,
what you're proposing isn't the "inverse" of what I said, it's the
same direction but you're assuming there's only one blocking process.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2013-03-22 14:29:15 Re: Strange Windows problem, lock_timeout test request
Previous Message Alvaro Herrera 2013-03-22 14:02:45 Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]