Skip to content

Commit 5fdab1e

Browse files
committed
Fix spurious warning after vacuuming a page on a table with no indexes.
There is a rare race condition, when a transaction that inserted a tuple aborts while vacuum is processing the page containing the inserted tuple. Vacuum prunes the page first, which normally removes any dead tuples, but if the inserting transaction aborts right after that, the loop after pruning will see a dead tuple and remove it instead. That's OK, but if the page is on a table with no indexes, and the page becomes completely empty after removing the dead tuple (or tuples) on it, it will be immediately marked as all-visible. That's OK, but the sanity check in vacuum would throw a warning because it thinks that the page contains dead tuples and was nevertheless marked as all-visible, even though it just vacuumed away the dead tuples and so it doesn't actually contain any. Spotted this while reading the code. It's difficult to hit the race condition otherwise, but can be done by putting a breakpoint after the heap_page_prune() call. Backpatch all the way to 8.4, where this code first appeared.
1 parent a6b831a commit 5fdab1e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
720720
{
721721
/* Remove tuples from heap */
722722
lazy_vacuum_page(onerel, blkno, buf, 0, vacrelstats);
723+
has_dead_tuples = false;
724+
723725
/* Forget the now-vacuumed tuples, and press on */
724726
vacrelstats->num_dead_tuples = 0;
725727
vacuumed_pages++;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy