Re: BUG #10123: Weird entries in pg_stat_activity - Mailing list pgsql-bugs

From Andres Freund
Subject Re: BUG #10123: Weird entries in pg_stat_activity
Date
Msg-id 20140424174641.GC32057@awork2.anarazel.de
Whole thread Raw
In response to Re: BUG #10123: Weird entries in pg_stat_activity  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On 2014-04-24 12:37:15 -0400, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > I think there's a pgstat_report_xact_timestamp(0) missing from
> > xact.c:PrepareTransaction(). There's no point in reporting a prepared
> > xact's starttime in a backend that's not associated with it anymore.
>
> > Maxim, are you using prepared transactions?
>
> Even if he were, that wouldn't explain this report, because the displayed
> latest-query would have to have been a PREPARE TRANSACTION, no?

Right. I think there's some other contents that could potentially end up
there, but surely not the SELECT Maxim is reporting. Especially not as
there seem to be several minutes inbetween the pg_stat_get_activity call
and the last state change...

> However, regardless of exactly what's going on here, I think you're
> probably right that PrepareTransaction ought to do
> pgstat_report_xact_timestamp(0) once it exits the transaction state
> locally.  The definition of that field is that it's null whenever the
> session isn't inside a transaction, and once we do PREPARE, we aren't.

Thanks for fixing it.

I don't really have a clue what's going on here. I don't believe
pgstat.c's changecount thing is 100% safe, but that doesn't explain the
problem here.

Greetings,

Andres Freund

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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #10123: Weird entries in pg_stat_activity
Next
From: Tom Lane
Date:
Subject: Re: BUG #10123: Weird entries in pg_stat_activity