Rearrange lazy_scan_heap to avoid visibility map race conditions.
We must set the visibility map bit before releasing our exclusive lock
on the heap page; otherwise, someone might clear the heap page bit
before we set the visibility map bit, leading to a situation where the
visibility map thinks the page is all-visible but it's really not.
This problem has existed since 8.4, but it wasn't critical before we
had index-only scans, since the worst case scenario was that the page
wouldn't get vacuumed until the next scan_all vacuum.
Along the way, a couple of minor, related improvements: (1) if we
pause the heap scan to do an index vac cycle, release any visibility
map page we're holding, since really long-running pins are not good
for a variety of reasons; and (2) warn if we see a page that's marked
all-visible in the visibility map but not on the page level, since
that should never happen any more (it was allowed in previous
releases, but not in 9.2).
src/backend/commands/vacuumlazy.c | 85 ++++++++++++++++++++-----------------
1 files changed, 46 insertions(+), 39 deletions(-)
pgsql-committers by date
|Next:||From: Robert Haas||Date: 2012-04-24 02:45:57|
|Subject: pgsql: Lots of doc corrections.|
|Previous:||From: Robert Haas||Date: 2012-04-24 02:07:03|
|Subject: pgsql: Reduce hash size for compute_array_stats,compute_tsvector_stats|