Fix a rare race condition when commit_siblings > 0 and a transaction commits
authorHeikki Linnakangas <[email protected]>
Tue, 31 Mar 2009 05:18:47 +0000 (05:18 +0000)
committerHeikki Linnakangas <[email protected]>
Tue, 31 Mar 2009 05:18:47 +0000 (05:18 +0000)
commit0ac8234ad967f28214b1a13399756917e4ff161b
tree6f9bc278bd95bc20e69f87ac3bb431ba1297243f
parentfa60dce2d0937de546d9d7e21423fbad332435a2
Fix a rare race condition when commit_siblings > 0 and a transaction commits
at the same instant as a new backend is spawned. Since CountActiveBackends()
doesn't hold ProcArrayLock, it needs to be prepared for the case that a
pointer at the end of the proc array is still NULL even though numProcs says
it should be valid, since it doesn't hold ProcArrayLock. Backpatch to 8.1.
8.0 and earlier had this right, but it was broken in the split of PGPROC and
sinval shared memory arrays.

Per report and proposal by Marko Kreen.
src/backend/storage/ipc/procarray.c