Skip to content

Commit b7a3e11

Browse files
committed
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.
1 parent 757ade4 commit b7a3e11

File tree

1 file changed

+2
-1
lines changed
  • src/backend/access/transam

1 file changed

+2
-1
lines changed

src/backend/access/transam/xact.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,8 +2113,9 @@ PrepareTransaction(void)
21132113
AtEOXact_Files();
21142114
AtEOXact_ComboCid();
21152115
AtEOXact_HashTables(true);
2116-
/* don't call AtEOXact_PgStat here */
2116+
/* don't call AtEOXact_PgStat here; we fixed pgstat state above */
21172117
AtEOXact_Snapshot(true);
2118+
pgstat_report_xact_timestamp(0);
21182119

21192120
CurrentResourceOwner = NULL;
21202121
ResourceOwnerDelete(TopTransactionResourceOwner);

0 commit comments

Comments
 (0)