Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e5d06f2

Browse files
committed
Dept of second thoughts: the !scan_all exit mustn't increase scanned_pages.
In the extreme edge case where contended pages are the only ones that escape being scanned, the previous commit would have allowed us to think that relfrozenxid could be advanced, which is exactly wrong.
1 parent e842908 commit e5d06f2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
666666
* to use lazy_check_needs_freeze() for both situations, though.
667667
*/
668668
LockBuffer(buf, BUFFER_LOCK_SHARE);
669-
if (!lazy_check_needs_freeze(buf, &hastup) || !scan_all)
669+
if (!lazy_check_needs_freeze(buf, &hastup))
670670
{
671671
UnlockReleaseBuffer(buf);
672672
vacrelstats->scanned_pages++;
@@ -675,6 +675,18 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
675675
vacrelstats->nonempty_pages = blkno + 1;
676676
continue;
677677
}
678+
if (!scan_all)
679+
{
680+
/*
681+
* Here, we must not advance scanned_pages; that would amount
682+
* to claiming that the page contains no freezable tuples.
683+
*/
684+
UnlockReleaseBuffer(buf);
685+
vacrelstats->pinskipped_pages++;
686+
if (hastup)
687+
vacrelstats->nonempty_pages = blkno + 1;
688+
continue;
689+
}
678690
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
679691
LockBufferForCleanup(buf);
680692
/* drop through to normal processing */

0 commit comments

Comments
 (0)