received from the GTM.
After our recent work on cluster monitor, GTM will now send back
latestCompletedXid and RecentGlobalXmin which we record in a shared memory
area. But if the node has not asked for XIDs for some time, the SLRU
maintaining these logs may fall much behind. So we must keep these log files
upto date with the XIDs generated by the GTM
This should also fix the spotting of the following log message as reported
by Mason Sharp
LOG: could not truncate directory "pg_subtrans": apparent wraparound
return result;
}
+
+#ifdef XCP
+void
+ExtendLogs(TransactionId xid)
+{
+ LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
+ ExtendCLOG(xid);
+ ExtendCommitTs(xid);
+ ExtendSUBTRANS(xid);
+ LWLockRelease(XidGenLock);
+}
+#endif
void
ClusterMonitorSetGlobalXmin(GlobalTransactionId xmin)
{
+ /*
+ * First extend the commit logs. Even though we may not have actually
+ * started any transactions in the new range, we must still extend the logs
+ * so that later operations which rely on the RecentGlobalXmin to truncate
+ * the logs work correctly.
+ */
+ ExtendLogs(xmin);
+
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
/*
if (!TransactionIdIsValid(latestCompletedXid))
return;
+ /*
+ * First extend the commit logs. Even though we may not have actually
+ * started any transactions in the new range, we must still extend the logs
+ * so that later operations which may try to query them based on the new
+ * value of latestCompletedXid do not throw errors
+ */
+ ExtendLogs(latestCompletedXid);
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
#ifdef XCP
extern bool TransactionIdIsCurrentGlobalTransactionId(TransactionId xid);
extern TransactionId GetNextTransactionId(void);
+extern void ExtendLogs(TransactionId xid);
#endif
extern TransactionId ReadNewTransactionId(void);
extern void SetTransactionIdLimit(TransactionId oldest_datfrozenxid,