Avoid hot standby cancels from VAC FREEZE
authorSimon Riggs <simon@2ndQuadrant.com>
Fri, 26 Jun 2015 23:48:06 +0000 (00:48 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Fri, 26 Jun 2015 23:48:06 +0000 (00:48 +0100)
VACUUM FREEZE generated false cancelations of standby queries on an
otherwise idle master. Caused by an off-by-one error on cutoff_xid
which goes back to original commit.

Backpatch to all versions 9.0+

Analysis and report by Marco Nenciarini

Bug fix by Simon Riggs

src/backend/access/heap/heapam.c

index 6645732f74c2f51974d3e2d12e2f0dc120048e32..634c0313c944e3fe472d6aca448ffaccd63e28e0 100644 (file)
@@ -4307,7 +4307,13 @@ heap_xlog_freeze(XLogRecPtr lsn, XLogRecord *record)
     * consider the frozen xids as running.
     */
    if (InHotStandby)
-       ResolveRecoveryConflictWithSnapshot(cutoff_xid, xlrec->node);
+   {
+       TransactionId latestRemovedXid = cutoff_xid;
+
+       TransactionIdRetreat(latestRemovedXid);
+
+       ResolveRecoveryConflictWithSnapshot(latestRemovedXid, rnode);
+   }
 
    /* If we have a full-page image, restore it and we're done */
    if (record->xl_info & XLR_BKP_BLOCK(0))