Re: Inconsistency between pg_stat_activity and log_duration - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: Inconsistency between pg_stat_activity and log_duration
Date
Msg-id 20140207.151622.517892175662113916.t-ishii@sraoss.co.jp
Whole thread Raw
In response to Re: Inconsistency between pg_stat_activity and log_duration  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: Inconsistency between pg_stat_activity and log_duration  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
> I think that is the probable reason for the above mentioned behaviour.
> As I understand here, the problem is that 'state' of backend is shown as
> active along with 'query' which according to docs (If state is active this field
> shows the currently executing query.) means that query is executing.
> 
> This statement holds true for simple query but for prepared statement
> (using message 'P', 'B', 'D', 'E', 'S') it might not be completely right as
> we update the state only after sync message which can confuse some
> users as you have stated. However I don't think it is good idea to change
> state in between different messages or at least with the current set of
> states.
> 
>> I think this inconsistency is not very intutive to users...
> 
> Do you think we can fix it in any easy way, or might be updating docs
> can make users understand the current situation better?

One idea is, calling pgstat_report_activity(STATE_IDLE) in
exec_execute_message() of postgres.c. The function has already called
pgstat_report_activity(STATE_RUNNING) which shows "active" state in
pg_stat_actviity view. So why cann't we call
pgstat_report_activity(STATE_IDLE) here.

Somebody might claim that "idle" is a transaction state term. In the
case, I propose to add new state name, say "finished". So above
proposal would calling pgstat_report_activity(STATE_FINISHED) instead.

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp



pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Typo in a comment?
Next
From: Amit Kapila
Date:
Subject: Re: Inconsistency between pg_stat_activity and log_duration