pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Geoghegan <pg@bowt.ie>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle parallel index builds on mapped relations.
Date: Fri, 10 Aug 2018 20:06:02 +0000
Message-ID: <E1foDfe-0000l2-A8@gemulon.postgresql.org> (raw)

Handle parallel index builds on mapped relations.

Commit 9da0cc35284, which introduced parallel CREATE INDEX, failed to
propagate relmapper.c backend local cache state to parallel worker
processes.  This could result in parallel index builds against mapped
catalog relations where the leader process (participating as a worker)
scans the new, pristine relfilenode, while worker processes scan the
obsolescent relfilenode.  When this happened, the final index structure
was typically not consistent with the owning table's structure.  The
final index structure could contain entries formed from both heap
relfilenodes.  Only rebuilds on mapped catalog relations that occur as
part of a VACUUM FULL or CLUSTER could become corrupt in practice, since
their mapped relation relfilenode swap is what allows the inconsistency
to arise.

On master, fix the problem by propagating the required relmapper.c
backend state as part of standard parallel initialization (Cf. commit
29d58fd3).  On v11, simply disallow builds against mapped catalog
relations by deeming them parallel unsafe.

Author: Peter Geoghegan
Reported-By: "death lock"
Reviewed-By: Tom Lane, Amit Kapila
Bug: #15309
Discussion: https://postgr.es/m/153329671686.1405.18298309097348420351@wrigleys.postgresql.org
Backpatch: 11-, where parallel CREATE INDEX was introduced.

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9353d94a9b70c6cbe181f78e49b2e8c1dc38eada

Modified Files
--------------
src/backend/optimizer/plan/planner.c |  8 +++++---
src/backend/utils/cache/relmapper.c  | 10 +++++++---
2 files changed, 12 insertions(+), 6 deletions(-)



view thread (2+ messages)

Message-ID: <E1foDfe-0000l2-A8@gemulon.postgresql.org>
Permalink:  ../E1foDfe-0000l2-A8@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1foDfe-0000l2-A8@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: pg@bowt.ie
  Subject: Re: pgsql: Handle parallel index builds on mapped relations.
  In-Reply-To: <E1foDfe-0000l2-A8@gemulon.postgresql.org>
  References: <E1foDfe-0000l2-A8@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