s->transactionId = GetNewTransactionId(isSubXact, &received_tp, >m_timestamp);
if (received_tp)
{
- GTMxactStartTimestamp = (TimestampTz) gtm_timestamp;
+ if (GTMxactStartTimestamp == 0)
+ GTMxactStartTimestamp = (TimestampTz) gtm_timestamp;
GTMdeltaTimestamp = GTMxactStartTimestamp - stmtStartTimestamp;
}
}
* from GTM along with GXID.
*/
#ifdef PGXC
+ if (GTMxactStartTimestamp == 0)
+ GTMxactStartTimestamp = xactStartTimestamp;
return GTMxactStartTimestamp;
#else
return xactStartTimestamp;
TimestampTz
GetCurrentGTMStartTimestamp(void)
{
+ if (GTMxactStartTimestamp == 0)
+ GTMxactStartTimestamp = xactStartTimestamp;
return GTMxactStartTimestamp;
}
#endif
void
SetCurrentGTMDeltaTimestamp(TimestampTz timestamp)
{
- GTMxactStartTimestamp = timestamp;
+ if (GTMxactStartTimestamp == 0)
+ GTMxactStartTimestamp = timestamp;
GTMdeltaTimestamp = GTMxactStartTimestamp - xactStartTimestamp;
}
#endif
xactStopTimestamp = 0;
#ifdef PGXC
/* For Postgres-XC, transaction start timestamp has to follow the GTM timeline */
- pgstat_report_xact_timestamp(GTMxactStartTimestamp);
+ pgstat_report_xact_timestamp(GTMxactStartTimestamp ?
+ GTMxactStartTimestamp :
+ xactStartTimestamp);
#else
pgstat_report_xact_timestamp(xactStartTimestamp);
#endif
#ifdef PGXC
AtEOXact_Remote();
+ GTMxactStartTimestamp = 0;
#endif
}
CleanGTMCallbacks();
#ifdef XCP
AtEOXact_Remote();
+ GTMxactStartTimestamp = 0;
#endif
#endif
#ifdef PGXC
AtEOXact_Remote();
+ GTMxactStartTimestamp = 0;
#endif
}