pgsql: Fix possible cache invalidation failure in ReceiveSharedInvalidM

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix possible cache invalidation failure in ReceiveSharedInvalidM
Date: 2014-05-05 18:44:17
Message-ID: E1WhNs9-0005J5-Kz@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix possible cache invalidation failure in ReceiveSharedInvalidMessages.

Commit fad153ec45299bd4d4f29dec8d9e04e2f1c08148 modified sinval.c to reduce
the number of calls into sinvaladt.c (which require taking a shared lock)
by keeping a local buffer of collected-but-not-yet-processed messages.
However, if processing of the last message in a batch resulted in a
recursive call to ReceiveSharedInvalidMessages, we could overwrite that
message with a new one while the outer invalidation function was still
working on it. This would be likely to lead to invalidation of the wrong
cache entry, allowing subsequent processing to use stale cache data.
The fix is just to make a local copy of each message while we're processing
it.

Spotted by Andres Freund. Back-patch to 8.4 where the bug was introduced.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/7d5b6862180b3e2ef4c34d5f0d397ae5825acd71

Modified Files
--------------
src/backend/storage/ipc/sinval.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-05-05 19:00:47 Re: pgsql: Fix pg_type.typlen for newly-revived line type.
Previous Message Alvaro Herrera 2014-05-05 18:26:11 Re: pgsql: Fix pg_type.typlen for newly-revived line type.