]> granicus.if.org Git - postgresql/commit
Avoid testing tuple visibility without buffer lock in RI_FKey_check().
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 23 Oct 2016 19:01:24 +0000 (15:01 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 23 Oct 2016 19:01:24 +0000 (15:01 -0400)
commit9bc01e7a4cd4d5ac0c9447a5885f3a5b1bd46dd0
treec7b3fc3b7cba7668f8cbe6980ececaa01095c022
parentafed471bf382fee399eaf7be0a417900a2cf0417
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>
src/backend/utils/adt/ri_triggers.c
src/test/regress/expected/foreign_key.out
src/test/regress/sql/foreign_key.sql