pgsql: Don't ignore tuple locks propagated by our updates

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Don't ignore tuple locks propagated by our updates
Date: 2013-12-18 16:49:52
Message-ID: E1VtKJk-0002k6-PJ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't ignore tuple locks propagated by our updates

If a tuple was locked by transaction A, and transaction B updated it,
the new version of the tuple created by B would be locked by A, yet
visible only to B; due to an oversight in HeapTupleSatisfiesUpdate, the
lock held by A wouldn't get checked if transaction B later deleted (or
key-updated) the new version of the tuple. This might cause referential
integrity checks to give false positives (that is, allow deletes that
should have been rejected).

This is an easy oversight to have made, because prior to improved tuple
locks in commit 0ac5ad5134f it wasn't possible to have tuples created by
our own transaction that were also locked by remote transactions, and so
locks weren't even considered in that code path.

It is recommended that foreign keys be rechecked manually in bulk after
installing this update, in case some referenced rows are missing with
some referencing row remaining.

Per bug reported by Daniel Wood in
CAPweHKe5QQ1747X2c0tA=5zf4YnS2xcvGf13Opd-1Mq24rF1cQ(at)mail(dot)gmail(dot)com

Branch
------
REL9_3_STABLE

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

Modified Files
--------------
src/backend/access/transam/multixact.c | 33 ++++++
src/backend/utils/time/tqual.c | 36 ++++++-
src/include/access/multixact.h | 1 +
.../isolation/expected/propagate-lock-delete.out | 105 ++++++++++++++++++++
src/test/isolation/isolation_schedule | 1 +
.../isolation/specs/propagate-lock-delete.spec | 42 ++++++++
6 files changed, 216 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2013-12-18 17:16:58 pgsql: Fix incorrect error message reported for non-existent users
Previous Message Tatsuo Ishii 2013-12-18 14:54:42 pgsql: Add ALTER SYSTEM command to edit the server configuration file.