pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Enable parallel query with SERIALIZABLE isolation.
Date: Fri, 15 Mar 2019 04:49:49 +0000
Message-ID: <E1h4emz-0002We-OE@gemulon.postgresql.org> (raw)

Enable parallel query with SERIALIZABLE isolation.

Previously, the SERIALIZABLE isolation level prevented parallel query
from being used.  Allow the two features to be used together by
sharing the leader's SERIALIZABLEXACT with parallel workers.

An extra per-SERIALIZABLEXACT LWLock is introduced to make it safe to
share, and new logic is introduced to coordinate the early release
of the SERIALIZABLEXACT required for the SXACT_FLAG_RO_SAFE
optimization, as follows:

The first backend to observe the SXACT_FLAG_RO_SAFE flag (set by
some other transaction) will 'partially release' the SERIALIZABLEXACT,
meaning that the conflicts and locks it holds are released, but the
SERIALIZABLEXACT itself will remain active because other backends
might still have a pointer to it.

Whenever any backend notices the SXACT_FLAG_RO_SAFE flag, it clears
its own MySerializableXact variable and frees local resources so that
it can skip SSI checks for the rest of the transaction.  In the
special case of the leader process, it transfers the SERIALIZABLEXACT
to a new variable SavedSerializableXact, so that it can be completely
released at the end of the transaction after all workers have exited.

Remove the serializable_okay flag added to CreateParallelContext() by
commit 9da0cc35, because it's now redundant.

Author: Thomas Munro
Reviewed-by: Haribabu Kommi, Robert Haas, Masahiko Sawada, Kevin Grittner
Discussion: https://postgr.es/m/CAEepm=0gXGYhtrVDWOTHS8SQQy_=S9xo+8oCxGLWZAOoeJ=yzQ@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/monitoring.sgml                       |   7 +-
doc/src/sgml/parallel.sgml                         |  17 --
src/backend/access/nbtree/nbtsort.c                |   2 +-
src/backend/access/transam/parallel.c              |  18 +-
src/backend/access/transam/xact.c                  |   7 +-
src/backend/executor/execParallel.c                |   2 +-
src/backend/optimizer/plan/planner.c               |  11 +-
src/backend/storage/lmgr/lwlock.c                  |   1 +
src/backend/storage/lmgr/predicate.c               | 237 +++++++++++++++++++--
src/backend/utils/resowner/resowner.c              |   2 +-
src/include/access/parallel.h                      |   3 +-
src/include/storage/lwlock.h                       |   1 +
src/include/storage/predicate.h                    |  11 +-
src/include/storage/predicate_internals.h          |  10 +
.../isolation/expected/serializable-parallel-2.out |  44 ++++
.../isolation/expected/serializable-parallel.out   |  44 ++++
src/test/isolation/isolation_schedule              |   2 +
.../isolation/specs/serializable-parallel-2.spec   |  30 +++
.../isolation/specs/serializable-parallel.spec     |  47 ++++
19 files changed, 429 insertions(+), 67 deletions(-)



Message-ID: <E1h4emz-0002We-OE@gemulon.postgresql.org>
Permalink:  ../E1h4emz-0002We-OE@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1h4emz-0002We-OE@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: tmunro@postgresql.org
  Subject: Re: pgsql: Enable parallel query with SERIALIZABLE isolation.
  In-Reply-To: <E1h4emz-0002We-OE@gemulon.postgresql.org>
  References: <E1h4emz-0002We-OE@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