diff options
author | Pavan Deolasee | 2015-12-08 09:05:21 +0000 |
---|---|---|
committer | Pavan Deolasee | 2015-12-08 09:05:21 +0000 |
commit | f4b99de06377420c63011251e56843e6c9d792e8 (patch) | |
tree | d21387791c282f3ab398b94c3687d9494f1cad17 | |
parent | da8eb3b85b7bd560ab728534dc4dd3f670ddd42a (diff) |
Acquire the right lock for updating latestCompletedXid.
Also make sure that the latestCompletedXid is updated on the nodes irrespective
of whather report-xmin returns success or failure
-rw-r--r-- | src/backend/postmaster/clustermon.c | 1 | ||||
-rw-r--r-- | src/backend/storage/ipc/procarray.c | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/postmaster/clustermon.c b/src/backend/postmaster/clustermon.c index d79aae8e1e..3cb7947354 100644 --- a/src/backend/postmaster/clustermon.c +++ b/src/backend/postmaster/clustermon.c @@ -239,6 +239,7 @@ ClusterMonitorInit(void) } else { + SetLatestCompletedXid(latestCompletedXid); ClusterMonitorSetReportedGlobalXmin(oldestXmin); elog(DEBUG2, "Updating global_xmin to %d", newOldestXmin); if (GlobalTransactionIdIsValid(newOldestXmin)) diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 420f27d17d..f91bf32324 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -4375,7 +4375,7 @@ SetLatestCompletedXid(TransactionId latestCompletedXid) if (!TransactionIdIsValid(latestCompletedXid)) return; - LWLockAcquire(XidGenLock, LW_EXCLUSIVE); + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); if (TransactionIdPrecedes(latestCompletedXid, ShmemVariableCache->latestCompletedXid)) @@ -4390,6 +4390,9 @@ SetLatestCompletedXid(TransactionId latestCompletedXid) volatile PGXACT *pgxact = &allPgXact[pgprocno]; TransactionId pxid = pgxact->xid; + if (!TransactionIdIsValid(pxid)) + continue; + if (TransactionIdPrecedesOrEquals(pxid, latestCompletedXid)) elog(PANIC, "Cannot set latestCompletedXid to %d while another " "process is running with an older xid %d", |