Skip site navigation (1) Skip section navigation (2)

pgsql: SSI has a race condition,where the order of commit sequence num

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: SSI has a race condition,where the order of commit sequence num
Date: 2011-07-07 20:35:09
Message-ID: E1QevHx-0001Yn-UF@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
SSI has a race condition, where the order of commit sequence numbers of
transactions might not match the order the work done in those transactions
become visible to others. The logic in SSI, however, assumed that it does.
Fix that by having two sequence numbers for each serializable transaction,
one taken before a transaction becomes visible to others, and one after it.
This is easier than trying to make the the transition totally atomic, which
would require holding ProcArrayLock and SerializableXactHashLock at the same
time. By using prepareSeqNo instead of commitSeqNo in a few places where
commit sequence numbers are compared, we can make those comparisons err on
the safe side when we don't know for sure which committed first.

Per analysis by Kevin Grittner and Dan Ports, but this approach to fix it
is different from the original patch.

Branch
------
REL9_1_STABLE

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

Modified Files
--------------
src/backend/storage/lmgr/predicate.c      |   29 +++++++++++------------------
src/include/storage/predicate_internals.h |   21 +++++++++++++++++++--
2 files changed, 30 insertions(+), 20 deletions(-)

pgsql-committers by date

Next:From: Heikki LinnakangasDate: 2011-07-07 21:48:33
Subject: pgsql: There's a small window wherein a transaction is committed butno
Previous:From: Heikki LinnakangasDate: 2011-07-07 20:29:56
Subject: pgsql: SSI has a race condition,where the order of commit sequence num

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group