]> granicus.if.org Git - postgresql/commit
SSI has a race condition, where the order of commit sequence numbers of
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 7 Jul 2011 19:35:09 +0000 (22:35 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 7 Jul 2011 20:32:25 +0000 (23:32 +0300)
commitfdf8f751e7933c7992cdabc4b8f37d25268f192e
tree8da32fdad7c90f5feca8bd09235537eba504261d
parent469345e1e3ae32c8c3c694f9a47cc6edccc5a274
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.
src/backend/storage/lmgr/predicate.c
src/include/storage/predicate_internals.h