summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Deolasee2016-02-15 10:47:11 +0000
committerPavan Deolasee2016-10-18 09:58:30 +0000
commit4c3bb336a23213c438ed52bff65b04d92f911885 (patch)
tree37285b3e1d3b67d3ea2b51d2fd8d0e5a1b5694b0
parent4771f06eeb0058985a4dd2d860eb48c7e77090e0 (diff)
Extend commit, subtrans and commit_ts logs appropriately when new xids are
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
-rw-r--r--src/backend/access/transam/varsup.c12
-rw-r--r--src/backend/postmaster/clustermon.c8
-rw-r--r--src/backend/storage/ipc/procarray.c7
-rw-r--r--src/include/access/transam.h1
4 files changed, 28 insertions, 0 deletions
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 1e601a68ca..56844d7001 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -777,3 +777,15 @@ GetNewObjectId(void)
return result;
}
+
+#ifdef XCP
+void
+ExtendLogs(TransactionId xid)
+{
+ LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
+ ExtendCLOG(xid);
+ ExtendCommitTs(xid);
+ ExtendSUBTRANS(xid);
+ LWLockRelease(XidGenLock);
+}
+#endif
diff --git a/src/backend/postmaster/clustermon.c b/src/backend/postmaster/clustermon.c
index 2ff09787ed..e2dda4f7f3 100644
--- a/src/backend/postmaster/clustermon.c
+++ b/src/backend/postmaster/clustermon.c
@@ -378,6 +378,14 @@ ClusterMonitorGetGlobalXmin(void)
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);
/*
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 216891485b..84b6a87d0d 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -4408,6 +4408,13 @@ SetLatestCompletedXid(TransactionId latestCompletedXid)
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);
diff --git a/src/include/access/transam.h b/src/include/access/transam.h
index 3011493cfa..c5ce762fba 100644
--- a/src/include/access/transam.h
+++ b/src/include/access/transam.h
@@ -188,6 +188,7 @@ extern TransactionId GetNewTransactionId(bool isSubXact);
#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,