From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix race condition in relcache init file invalidation. |
Date: | 2011-08-16 17:13:10 |
Message-ID: | E1QtNCQ-0003Eu-8R@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/2ada6779c5d3fcc31568ba263f8a0cc9bb8318c1
Modified Files
--------------
src/backend/access/transam/twophase.c | 4 +-
src/backend/utils/cache/inval.c | 33 ++++++++--------
src/backend/utils/cache/relcache.c | 66 ++++++++++++++++++---------------
src/include/utils/relcache.h | 3 +-
4 files changed, 57 insertions(+), 49 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-08-16 17:48:41 | pgsql: Preserve toast value OIDs in toast-swap-by-content for CLUSTER/V |
Previous Message | User Cunha17 | 2011-08-16 15:54:12 | snapshot - src: FIX: Support for PostGIS datatypes Geometry and |