diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 32b6fdd..98cf9e8 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -1183,6 +1183,23 @@ lazy_scan_heap(Relation onerel, int options, LVRelStats *vacrelstats, } /* + * If the page contains non-frozen tuples but the visibility map is + * telling the contrary, inform of the situation and take preventive + * measures on the page and the visibility map. This situation should + * not happen however. + */ + else if (all_visible_according_to_vm && + VM_ALL_FROZEN(onerel, blkno, &vmbuffer) && + !all_frozen) + { + elog(WARNING, "page contains non-frozen tuples but visibility map bit is set in relation \"%s\" page %u", + relname, blkno); + PageClearAllVisible(page); + MarkBufferDirty(buf); + visibilitymap_clear(onerel, blkno, vmbuffer); + } + + /* * It's possible for the value returned by GetOldestXmin() to move * backwards, so it's not wrong for us to see tuples that appear to * not be visible to everyone yet, while PD_ALL_VISIBLE is already