pgsql: Harden nbtree page deletion. - Mailing list pgsql-committers

From Peter Geoghegan
Subject pgsql: Harden nbtree page deletion.
Date
Msg-id E1l7oHo-0002Su-Fg@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Harden nbtree page deletion.

Add some additional defensive checks in the second phase of index
deletion to detect and report index corruption during VACUUM, and to
avoid having VACUUM become stuck in more cases.  The code is still not
robust in the presence of a circular chain of sibling links, though it's
not clear whether that really matters.  This is follow-up work to commit
3a01f68e.

The new defensive checks rely on the assumption that there can be no
more than one VACUUM operation running for an index at any given time.
Remove an old comment suggesting that multiple concurrent VACUUMs need
to be considered here.  This concern now seems highly unlikely to have
any real validity, since we clearly rely on the same assumption in
several other places.  For example, there are much more recent comments
that appear in the same function (added by commit efada2b8e92) that make
the same assumption.

Also add a CHECK_FOR_INTERRUPTS() to the relevant code path.  Contrary
to comments added by commit 3a01f68e, it is actually possible to handle
interrupts here, at least in the common case where processing takes
place at the leaf level.  We only hold a pin on leafbuf/target page when
stepping right at the leaf level.

No backpatch due to the lack of complaints following hardening added to
the same area by commit 3a01f68e.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c34787f910585f82320f78b0afd53a6a170aa229

Modified Files
--------------
src/backend/access/nbtree/nbtpage.c | 64 ++++++++++++++++++++++---------------
1 file changed, 38 insertions(+), 26 deletions(-)


pgsql-committers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix small error in COPY FROM progress reporting.
Next
From: Tom Lane
Date:
Subject: pgsql: Fix YA incremental sort bug.