pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Avoid testing tuple visibility without buffer lock in RI_FKey_ch
Date: Sun, 23 Oct 2016 19:02:38 +0000
Message-ID: <E1byO2Y-00040q-1y@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Avoid testing tuple visibility without buffer lock in RI_FKey_check().

Despite the argumentation I wrote in commit 7a2fe85b0, it's unsafe to do
this, because in corner cases it's possible for HeapTupleSatisfiesSelf
to try to set hint bits on the target tuple; and at least since 8.2 we
have required the buffer content lock to be held while setting hint bits.

The added regression test exercises one such corner case.  Unpatched, it
causes an assertion failure in assert-enabled builds, or otherwise would
cause a hint bit change in a buffer we don't hold lock on, which given
the right race condition could result in checksum failures or other data
consistency problems.  The odds of a problem in the field are probably
pretty small, but nonetheless back-patch to all supported branches.

Report: <19391.1477244876@sss.pgh.pa.us>

Branch
------
REL9_1_STABLE

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

Modified Files
--------------
src/backend/utils/adt/ri_triggers.c       | 20 +++++++++-----------
src/test/regress/expected/foreign_key.out | 22 ++++++++++++++++++++++
src/test/regress/sql/foreign_key.sql      | 23 +++++++++++++++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)


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


view thread (10+ messages)  latest in thread

Message-ID: <E1byO2Y-00040q-1y@gemulon.postgresql.org>
Permalink:  ../E1byO2Y-00040q-1y@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1byO2Y-00040q-1y@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid testing tuple visibility without buffer lock in RI_FKey_ch
  In-Reply-To: <E1byO2Y-00040q-1y@gemulon.postgresql.org>
  References: <E1byO2Y-00040q-1y@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