Skip to content

Commit 6537a48

Browse files
committed
Avoid hot standby cancels from VAC FREEZE
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. Analysis and report by Marco Nenciarini Bug fix by Simon Riggs This is a correct backpatch of commit 66fbcb0 to branches 9.1 through 9.4. That commit was backpatched to 9.0 originally, but it was immediately reverted in 9.0-9.4 because it didn't compile.
1 parent 4632076 commit 6537a48

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/backend/access/heap/heapam.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6928,7 +6928,13 @@ heap_xlog_freeze(XLogRecPtr lsn, XLogRecord *record)
69286928
* consider the frozen xids as running.
69296929
*/
69306930
if (InHotStandby)
6931-
ResolveRecoveryConflictWithSnapshot(cutoff_xid, xlrec->node);
6931+
{
6932+
TransactionId latestRemovedXid = cutoff_xid;
6933+
6934+
TransactionIdRetreat(latestRemovedXid);
6935+
6936+
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, xlrec->node);
6937+
}
69326938

69336939
/* If we have a full-page image, restore it and we're done */
69346940
if (record->xl_info & XLR_BKP_BLOCK(0))
@@ -7103,7 +7109,13 @@ heap_xlog_freeze_page(XLogRecPtr lsn, XLogRecord *record)
71037109
* consider the frozen xids as running.
71047110
*/
71057111
if (InHotStandby)
7106-
ResolveRecoveryConflictWithSnapshot(cutoff_xid, xlrec->node);
7112+
{
7113+
TransactionId latestRemovedXid = cutoff_xid;
7114+
7115+
TransactionIdRetreat(latestRemovedXid);
7116+
7117+
ResolveRecoveryConflictWithSnapshot(latestRemovedXid, xlrec->node);
7118+
}
71077119

71087120
/* If we have a full-page image, restore it and we're done */
71097121
if (record->xl_info & XLR_BKP_BLOCK(0))

0 commit comments

Comments
 (0)