postgres.git / summary / log / commit / refs
commit 12e41a5d70d5a96ed5859e7f0cd6047329b3d8d7
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu Apr 24 17:29:48 2014 +0000
First released in: 9.4.0, 8.4.22, 9.0.18, 9.1.14, 9.2.9, 9.3.5
Reset pg_stat_activity.xact_start during PREPARE TRANSACTION.
Once we've completed a PREPARE, our session is not running a transaction,
so its entry in pg_stat_activity should show xact_start as null, rather
than leaving the value as the start time of the now-prepared transaction.
I think possibly this oversight was triggered by faulty extrapolation
from the adjacent comment that says PrepareTransaction should not call
AtEOXact_PgStat, so tweak the wording of that comment.
Noted by Andres Freund while considering bug #10123 from Maxim Boguk,
although this error doesn't seem to explain that report.
Back-patch to all active branches.
src/backend/access/transam/xact.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index fd5f71015fa..77bf9748352 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2233,8 +2233,9 @@ PrepareTransaction(void)
AtEOXact_Files();
AtEOXact_ComboCid();
AtEOXact_HashTables(true);
- /* don't call AtEOXact_PgStat here */
+ /* don't call AtEOXact_PgStat here; we fixed pgstat state above */
AtEOXact_Snapshot(true);
+ pgstat_report_xact_timestamp(0);
CurrentResourceOwner = NULL;
ResourceOwnerDelete(TopTransactionResourceOwner);
[parent: cb651b624dab]