]> granicus.if.org Git - postgresql/commit
Fix race condition in relcache init file invalidation.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 16 Aug 2011 17:12:23 +0000 (13:12 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 16 Aug 2011 17:12:23 +0000 (13:12 -0400)
commit8407a11c5a004671142a9ac2fe29de3844360b0b
tree20dda460bf0bd7e152802d42f50c0dc8ba2e0c49
parentd52555576887cb408b11589a2c07d5b2d06f892d
Fix race condition in relcache init file invalidation.

The previous code tried to synchronize by unlinking the init file twice,
but that doesn't actually work: it leaves a window wherein a third process
could read the already-stale init file but miss the SI messages that would
tell it the data is stale.  The result would be bizarre failures in catalog
accesses, typically "could not read block 0 in file ..." later during
startup.

Instead, hold RelCacheInitLock across both the unlink and the sending of
the SI messages.  This is more straightforward, and might even be a bit
faster since only one unlink call is needed.

This has been wrong since it was put in (in 2002!), so back-patch to all
supported releases.
src/backend/utils/cache/inval.c
src/backend/utils/cache/relcache.c
src/include/utils/relcache.h