Re: xact_start meaning when dealing with procedures?

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, depesz(at)depesz(dot)com, pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: xact_start meaning when dealing with procedures?
Date: 2018-08-10 08:39:57
Message-ID: dd98fc8b-0d62-438c-184e-713d05616d41@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09/08/2018 20:25, Vik Fearing wrote:
> On 09/08/18 20:13, Peter Eisentraut wrote:
>> On 09/08/2018 19:57, hubert depesz lubaczewski wrote:
>>> I just noticed that when I called a procedure that commits and rollbacks
>>> - the xact_start in pg_stat_activity is not updated. Is it intentional?
>>
>> It's an artifact of the way this is computed. The reported transaction
>> timestamp is the timestamp of the first top-level statement of the
>> transaction. This assumes that transactions contain statements, not the
>> other way around, like it is now possible. I'm not sure what an
>> appropriate improvement would be here.
>
> That would just mean that query_start would be older than xact_start,
> but that's okay because the displayed query would be a CALL so we'll
> know what's going on.

Note that this issue already exists for other commands that start
transactions internally, such as VACUUM and CREATE INDEX CONCURRENTLY.
At the moment, one should interpret xact_start as referring to the
top-level transaction only.

In practice, I think the value of xact_start versus query_start is to
anayze idle transactions. This doesn't happen with internal
transactions, so it's not a big deal in practice.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2018-08-10 09:00:37 log_temp_files associated with "wrong" statement
Previous Message Fabien COELHO 2018-08-10 08:33:37 Re: [HACKERS] WIP Patch: Pgbench Serialization and deadlock errors