pgsql: Overdue code review for transaction-level advisory locks patch. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Overdue code review for transaction-level advisory locks patch.
Date
Msg-id E1SQQIt-0000Ih-71@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Overdue code review for transaction-level advisory locks patch.

Commit 62c7bd31c8878dd45c9b9b2429ab7a12103f3590 had assorted problems, most
visibly that it broke PREPARE TRANSACTION in the presence of session-level
advisory locks (which should be ignored by PREPARE), as per a recent
complaint from Stephen Rees.  More abstractly, the patch made the
LockMethodData.transactional flag not merely useless but outright
dangerous, because in point of fact that flag no longer tells you anything
at all about whether a lock is held transactionally.  This fix therefore
removes that flag altogether.  We now rely entirely on the convention
already in use in lock.c that transactional lock holds must be owned by
some ResourceOwner, while session holds are never so owned.  Setting the
locallock struct's owner link to NULL thus denotes a session hold, and
there is no redundant marker for that.

PREPARE TRANSACTION now works again when there are session-level advisory
locks, and it is also able to transfer transactional advisory locks to the
prepared transaction, but for implementation reasons it throws an error if
we hold both types of lock on a single lockable object.  Perhaps it will be
worth improving that someday.

Assorted other minor cleanup and documentation editing, as well.

Back-patch to 9.1, except that in the 9.1 branch I did not remove the
LockMethodData.transactional flag for fear of causing an ABI break for
any external code that might be examining those structs.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/1c0e678678a661f8437ed238a5c515b81547aaf4

Modified Files
--------------
doc/src/sgml/func.sgml          |   67 +++++++-------
doc/src/sgml/mvcc.sgml          |   76 +++++++++------
src/backend/storage/lmgr/README |   16 ++--
src/backend/storage/lmgr/lock.c |  198 ++++++++++++++++++++++++---------------
src/backend/storage/lmgr/proc.c |   10 +-
src/include/storage/lock.h      |    4 +-
6 files changed, 217 insertions(+), 154 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Overdue code review for transaction-level advisory locks patch.
Next
From: Bruce Momjian
Date:
Subject: pgsql: Fix psql doc typo.