aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-04-24 13:29:48 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2014-04-24 13:30:04 -0400
commit70e7be2647106c30784627e69b9d92342e77dc3e (patch)
tree4db2505ae613d93cfbe9d1c76263de314f011876
parentd1d2845287d74e8734f55592c6eeea4dcaae9949 (diff)
downloadpostgresql-70e7be2647106c30784627e69b9d92342e77dc3e.tar.gz
postgresql-70e7be2647106c30784627e69b9d92342e77dc3e.zip
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.
-rw-r--r--src/backend/access/transam/xact.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index c8c37dc9d7d..cc5b71ecb08 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2167,8 +2167,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);