diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-12-30 17:32:23 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-12-30 17:32:23 -0500 |
commit | e5d06f2b12a7c75f2b0c7fd2055a14efaa2b59ec (patch) | |
tree | 6614442648db2d5368343e400bd873705fa00a5e | |
parent | e842908233bb9c5cea0e765fc828b52badd8228e (diff) | |
download | postgresql-e5d06f2b12a7c75f2b0c7fd2055a14efaa2b59ec.tar.gz postgresql-e5d06f2b12a7c75f2b0c7fd2055a14efaa2b59ec.zip |
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.
-rw-r--r-- | src/backend/commands/vacuumlazy.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index a93d4a1f238..2a8cab746a9 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -666,7 +666,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, * to use lazy_check_needs_freeze() for both situations, though. */ LockBuffer(buf, BUFFER_LOCK_SHARE); - if (!lazy_check_needs_freeze(buf, &hastup) || !scan_all) + if (!lazy_check_needs_freeze(buf, &hastup)) { UnlockReleaseBuffer(buf); vacrelstats->scanned_pages++; @@ -675,6 +675,18 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, vacrelstats->nonempty_pages = blkno + 1; continue; } + if (!scan_all) + { + /* + * Here, we must not advance scanned_pages; that would amount + * to claiming that the page contains no freezable tuples. + */ + UnlockReleaseBuffer(buf); + vacrelstats->pinskipped_pages++; + if (hastup) + vacrelstats->nonempty_pages = blkno + 1; + continue; + } LockBuffer(buf, BUFFER_LOCK_UNLOCK); LockBufferForCleanup(buf); /* drop through to normal processing */ |