pgsql: Do all-visible handling in lazy_vacuum_page() outside its critic

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Do all-visible handling in lazy_vacuum_page() outside its critic
Date: 2014-06-20 09:10:01
Message-ID: E1Wxupd-0001DZ-BP@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Do all-visible handling in lazy_vacuum_page() outside its critical section.

Since fdf9e21196a lazy_vacuum_page() rechecks the all-visible status
of pages in the second pass over the heap. It does so inside a
critical section, but both visibilitymap_test() and
heap_page_is_all_visible() perform operations that should not happen
inside one. The former potentially performs IO and both potentially do
memory allocations.

To fix, simply move all the all-visible handling outside the critical
section. Doing so means that the PD_ALL_VISIBLE on the page won't be
included in the full page image of the HEAP2_CLEAN record anymore. But
that's fine, the flag will be set by the HEAP2_VISIBLE logged later.

Backpatch to 9.3 where the problem was introduced. The bug only came
to light due to the assertion added in 4a170ee9 and isn't likely to
cause problems in production scenarios. The worst outcome is a
avoidable PANIC restart.

This also gets rid of the difference in the order of operations
between master and standby mentioned in 2a8e1ac5.

Per reports from David Leverton and Keith Fiske in bug #10533.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ecac0e2b9e8e8e78d771b20fe441e95bb02db2fa

Modified Files
--------------
src/backend/commands/vacuumlazy.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2014-06-20 09:11:06 pgsql: Do all-visible handling in lazy_vacuum_page() outside its critic
Previous Message Noah Misch 2014-06-20 03:02:21 Re: pgsql: Let installcheck-world pass against a server requiring a passwor

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeevan Chalke 2014-06-20 10:17:00 Re: add line number as prompt option to psql
Previous Message Kyotaro HORIGUCHI 2014-06-20 08:04:06 Re: inherit support for foreign tables