pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Prevent GIN deleted pages from being reclaimed too early
Date: Thu, 13 Dec 2018 03:56:01 +0000
Message-ID: <E1gXI6T-0005RR-Cd@gemulon.postgresql.org> (raw)

Prevent GIN deleted pages from being reclaimed too early

When GIN vacuum deletes a posting tree page, it assumes that no concurrent
searchers can access it, thanks to ginStepRight() locking two pages at once.
However, since 9.4 searches can skip parts of posting trees descending from the
root.  That leads to the risk that page is deleted and reclaimed before
concurrent search can access it.

This commit prevents the risk of above by waiting for every transaction, which
might wait to reference this page, to finish.  Due to binary compatibility
we can't change GinPageOpaqueData to store corresponding transaction id.
Instead we reuse page header pd_prune_xid field, which is unused in index pages.

Discussion: https://postgr.es/m/31a702a.14dd.166c1366ac1.Coremail.chjischj%40163.com
Author: Andrey Borodin, Alexander Korotkov
Reviewed-by: Alexander Korotkov
Backpatch-through: 9.4

Branch
------
REL_10_STABLE

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

Modified Files
--------------
src/backend/access/gin/README      | 10 ++++------
src/backend/access/gin/ginutil.c   |  7 +------
src/backend/access/gin/ginvacuum.c |  6 +++++-
src/backend/access/gin/ginxlog.c   |  1 +
src/include/access/ginblock.h      | 10 ++++++++++
src/include/access/ginxlog.h       |  1 +
6 files changed, 22 insertions(+), 13 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1gXI6T-0005RR-Cd@gemulon.postgresql.org>
Permalink:  ../E1gXI6T-0005RR-Cd@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gXI6T-0005RR-Cd@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org
  Subject: Re: pgsql: Prevent GIN deleted pages from being reclaimed too early
  In-Reply-To: <E1gXI6T-0005RR-Cd@gemulon.postgresql.org>
  References: <E1gXI6T-0005RR-Cd@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox