pgsql: Fix race condition in DELETE RETURNING.

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 DELETE RETURNING.
Date: 2013-03-10 23:19:12
Message-ID: E1UEpWK-0002L7-9s@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix race condition in DELETE RETURNING.

When RETURNING is specified, ExecDelete would return a virtual-tuple slot
that could contain pointers into an already-unpinned disk buffer. Another
process could change the buffer contents before we get around to using the
data, resulting in garbage results or even a crash. This seems of fairly
low probability, which may explain why there are no known field reports of
the problem, but it's definitely possible. Fix by forcing the result slot
to be "materialized" before we release pin on the disk buffer.

Back-patch to 9.0; in earlier branches there is no bug because
ExecProcessReturning sent the tuple to the destination immediately. Also,
this is already fixed in HEAD as part of the writable-foreign-tables patch
(where the fix is necessary for DELETE RETURNING to work at all with
postgres_fdw).

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/8d4bb31618c6f4f251e372cef62a86bb2f9cd1b4

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2013-03-11 16:00:31 pgsql: Fix thinko in matview patch.
Previous Message Andrew Dunstan 2013-03-10 21:36:07 pgsql: JSON generation improvements.