pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <kgrittn@postgresql.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Detect SSI conflicts before reporting constraint violations
Date: Thu, 07 Apr 2016 16:14:02 +0000
Message-ID: <E1aoCZG-0004rH-Uk@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Detect SSI conflicts before reporting constraint violations

While prior to this patch the user-visible effect on the database
of any set of successfully committed serializable transactions was
always consistent with some one-at-a-time order of execution of
those transactions, the presence of declarative constraints could
allow errors to occur which were not possible in any such ordering,
and developers had no good workarounds to prevent user-facing
errors where they were not necessary or desired.  This patch adds
a check for serialization failure ahead of duplicate key checking
so that if a developer explicitly (redundantly) checks for the
pre-existing value they will get the desired serialization failure
where the problem is caused by a concurrent serializable
transaction; otherwise they will get a duplicate key error.

While it would be better if the reads performed by the constraints
could count as part of the work of the transaction for
serialization failure checking, and we will hopefully get there
some day, this patch allows a clean and reliable way for developers
to work around the issue.  In many cases existing code will already
be doing the right thing for this to "just work".

Author: Thomas Munro, with minor editing of docs by me
Reviewed-by: Marko Tiikkaja, Kevin Grittner

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/mvcc.sgml                             | 35 ++++++++++++----
src/backend/access/nbtree/nbtinsert.c              |  8 ++++
.../isolation/expected/read-write-unique-2.out     | 29 +++++++++++++
.../isolation/expected/read-write-unique-3.out     | 12 ++++++
.../isolation/expected/read-write-unique-4.out     | 41 ++++++++++++++++++
src/test/isolation/expected/read-write-unique.out  | 29 +++++++++++++
src/test/isolation/isolation_schedule              |  4 ++
src/test/isolation/specs/read-write-unique-2.spec  | 36 ++++++++++++++++
src/test/isolation/specs/read-write-unique-3.spec  | 33 +++++++++++++++
src/test/isolation/specs/read-write-unique-4.spec  | 48 ++++++++++++++++++++++
src/test/isolation/specs/read-write-unique.spec    | 39 ++++++++++++++++++
11 files changed, 307 insertions(+), 7 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1aoCZG-0004rH-Uk@gemulon.postgresql.org>
Permalink:  ../E1aoCZG-0004rH-Uk@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1aoCZG-0004rH-Uk@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: kgrittn@postgresql.org
  Subject: Re: pgsql: Detect SSI conflicts before reporting constraint violations
  In-Reply-To: <E1aoCZG-0004rH-Uk@gemulon.postgresql.org>
  References: <E1aoCZG-0004rH-Uk@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