Skip site navigation (1) Skip section navigation (2)

pgsql: Rearrange lazy_scan_heap to avoid visibility map raceconditions

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rearrange lazy_scan_heap to avoid visibility map raceconditions
Date: 2012-04-24 02:19:16
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
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).



Modified Files
src/backend/commands/vacuumlazy.c |   85 ++++++++++++++++++++-----------------
1 files changed, 46 insertions(+), 39 deletions(-)

pgsql-committers by date

Next:From: Robert HaasDate: 2012-04-24 02:45:57
Subject: pgsql: Lots of doc corrections.
Previous:From: Robert HaasDate: 2012-04-24 02:07:03
Subject: pgsql: Reduce hash size for compute_array_stats,compute_tsvector_stats

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group