pgsql: Move RegisterPredicateLockingXid() call to a safer place.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Move RegisterPredicateLockingXid() call to a safer place.
Date: 2011-05-06 16:58:11
Message-ID: E1QIOLz-00006C-9o@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Move RegisterPredicateLockingXid() call to a safer place.

The SSI patch inserted a call of RegisterPredicateLockingXid into
GetNewTransactionId, which was a bad idea on a couple of grounds. First,
it's not necessary to hold XidGenLock while manipulating that shared
memory, and doing so is bad because XidGenLock is a high-contention lock
that should be held for as short a time as possible. (Not to mention that
it adds an entirely unnecessary deadlock hazard, since we must take
SerializableXactHashLock as well.) Second, the specific place where it was
put was between extending CLOG and advancing nextXid, which could result in
unpleasant behavior in case of a failure there. Pull the call out to
AssignTransactionId, which is much safer and arguably better from a
modularity standpoint too.

There is more work to do to clean up the failure-before-advancing-nextXid
issue, but that is a separate change that will need to be back-patched.
So for the moment I just want to make GetNewTransactionId look the same as
it did in prior versions.

Branch
------
master

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

Modified Files
--------------
src/backend/access/transam/varsup.c | 5 -----
src/backend/access/transam/xact.c | 7 +++++++
2 files changed, 7 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2011-05-06 20:07:30 pgsql: Improve compiler string shown in version()
Previous Message Tom Lane 2011-05-06 00:39:24 pgsql: Remove precedence labeling of keywords TRUE, FALSE, UNKNOWN, and