trivial patch: show SIREAD pids in pg_locks

Lists: pgsql-hackers
From: Dan Ports <drkp(at)csail(dot)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Subject: trivial patch: show SIREAD pids in pg_locks
Date: 2011-04-01 17:00:28
Message-ID: 20110401170028.GK81592@csail.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

While looking into a SSI bug, I noticed that we don't actually display
the pid of the holding transaction, even though we have that
information available.

The attached patch fixes that.

One note is that it will show the pid of the backend that executed the
transaction, even if that transaction has already committed. I have no
particular opinion about whether it's more useful to do that or return
null, so went with the smallest change. (The pid is null for PREPARED
or summarized transactions).

Dan

--
Dan R. K. Ports MIT CSAIL http://drkp.net/

Attachment Content-Type Size
patch-ssi-pid-in-pg_locks.diff text/x-diff 572 bytes

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Dan Ports" <drkp(at)csail(dot)mit(dot)edu>,<pgsql-hackers(at)postgresql(dot)org>
Subject: Re: trivial patch: show SIREAD pids in pg_locks
Date: 2011-04-01 17:20:25
Message-ID: 4D95C309020000250003C140@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dan Ports <drkp(at)csail(dot)mit(dot)edu> wrote:
> While looking into a SSI bug, I noticed that we don't actually
> display the pid of the holding transaction, even though we have
> that information available.

I thought we already had that, but clearly I was mistaken.

> The attached patch fixes that.
>
> One note is that it will show the pid of the backend that executed
> the transaction, even if that transaction has already committed. I
> have no particular opinion about whether it's more useful to do
> that or return null, so went with the smallest change. (The pid is
> null for PREPARED or summarized transactions).

The patch looks good to me and a quick test shows the expected
behavior. No warnings. Regression tests pass.

I guess the question is whether it's OK to include this during the
alpha testing phase. Even though it's a little bit of a stretch to
call it a bug, the argument could be made that omitting information
which all the other rows in the view have is an inconsistency which
borders on being a bug. The small size and verifiable safety of the
patch work in its favor.

-Kevin


From: Dan Ports <drkp(at)csail(dot)mit(dot)edu>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: trivial patch: show SIREAD pids in pg_locks
Date: 2011-04-01 18:42:55
Message-ID: 20110401184255.GM81592@csail.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Apr 01, 2011 at 12:20:25PM -0500, Kevin Grittner wrote:
> I thought we already had that, but clearly I was mistaken.

Yeah, so did I. Turns out we had the vxid but not the pid. IIRC, we
weren't tracking a SERIALIZABLEXACT's pid yet, at the time we wrote the
code for pg_locks.

> I guess the question is whether it's OK to include this during the
> alpha testing phase. Even though it's a little bit of a stretch to
> call it a bug, the argument could be made that omitting information
> which all the other rows in the view have is an inconsistency which
> borders on being a bug. The small size and verifiable safety of the
> patch work in its favor.

There's no urgent need to have this, although it's obviously more
correct than the current behavior. It might be useful for debugging. The
patch is also all of four lines. :-)

Dan

--
Dan R. K. Ports MIT CSAIL http://drkp.net/


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Dan Ports" <drkp(at)csail(dot)mit(dot)edu>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: trivial patch: show SIREAD pids in pg_locks
Date: 2011-04-01 19:23:00
Message-ID: 4D95DFC4020000250003C146@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dan Ports <drkp(at)csail(dot)mit(dot)edu> wrote:

> There's no urgent need to have this, although it's obviously more
> correct than the current behavior. It might be useful for
> debugging.

Agreed all around. For the benefit of the more casual follower of
the thread, attached is a simple example of the output. For the
SIReadLock rows, the pid column shows as empty without the patch.

-Kevin

Attachment Content-Type Size
patch-ssi-pid-in-pg_locks.txt text/plain 1.4 KB

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Dan Ports <drkp(at)csail(dot)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Subject: Re: trivial patch: show SIREAD pids in pg_locks
Date: 2011-04-01 21:02:59
Message-ID: 1301691779.3678.1.camel@jdavis-ux.asterdata.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2011-04-01 at 13:00 -0400, Dan Ports wrote:
> While looking into a SSI bug, I noticed that we don't actually display
> the pid of the holding transaction, even though we have that
> information available.

Is there a chance that the PID will reference a backend that has either
terminated or is idle? That might be confusing.

Regards,
Jeff Davis


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Dan Ports" <drkp(at)csail(dot)mit(dot)edu>,"Jeff Davis" <pgsql(at)j-davis(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: trivial patch: show SIREAD pids in pg_locks
Date: 2011-04-01 21:17:03
Message-ID: 4D95FA7F020000250003C171@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> On Fri, 2011-04-01 at 13:00 -0400, Dan Ports wrote:
>> While looking into a SSI bug, I noticed that we don't actually
>> display the pid of the holding transaction, even though we have
>> that information available.
>
> Is there a chance that the PID will reference a backend that has
> either terminated or is idle?

Yes to both.

> That might be confusing.

With a barely larger patch we could suppress that, if that's
desirable. Of course, there is already the same issue for the
virtualtransaction column.

As Dan mentioned, it won't show for locks which are summarized using
SLRU, nor will it show for prepared transactions pending final
commit -- at least if they're loaded from disk after recovery. (I'm
not sure without some digging about a transaction which is prepared
and still pending commit if the server is still running from the
point of prepare.)

-Kevin


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Dan Ports <drkp(at)csail(dot)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Subject: Re: trivial patch: show SIREAD pids in pg_locks
Date: 2011-04-04 17:24:15
Message-ID: BANLkTik88cWDZaL_3Er8p7tNbpaWt1054A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Apr 1, 2011 at 1:00 PM, Dan Ports <drkp(at)csail(dot)mit(dot)edu> wrote:
> While looking into a SSI bug, I noticed that we don't actually display
> the pid of the holding transaction, even though we have that
> information available.
>
> The attached patch fixes that.

Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company