Move call to GetTopTransactionId() earlier in LockAcquire(),

Simon Riggs <simon@2ndQuadrant.com>

Commit: 09425f89e764beabbdd30cc877b3de96f5d3d2b9
Author: Simon Riggs <simon@2ndQuadrant.com>
Date: 2010-11-29T01:10:56Z
Releases: 9.0.2
Move call to GetTopTransactionId() earlier in LockAcquire(),
removing an infrequently occurring race condition in Hot Standby.
An xid must be assigned before a lock appears in shared memory,
rather than immediately after, else GetRunningTransactionLocks()
may see InvalidTransactionId, causing assertion failures during
lock processing on standby.

Bug report and diagnosis by Fujii Masao, fix by me.

Files

PathChange+/−
src/backend/storage/ipc/standby.c modified +21 −8
src/backend/storage/lmgr/lock.c modified +21 −8
src/include/storage/standby.h modified +1 −0