pgsql: Fix unsafe order of operations in foreign-table DDL commands.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix unsafe order of operations in foreign-table DDL commands.
Date: 2011-08-14 19:41:00
Message-ID: E1QsgYO-0005S6-R2@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix unsafe order of operations in foreign-table DDL commands.

When updating or deleting a system catalog tuple, it's necessary to acquire
RowExclusiveLock on the catalog before looking up the tuple; otherwise a
concurrent VACUUM FULL on the catalog might move the tuple to a different
TID before we can apply the update. Coding patterns that find the tuple
via a table scan aren't at risk here, but when obtaining the tuple from a
catalog cache, correct ordering is important; and several routines in
foreigncmds.c got it wrong. Noted while running the regression tests in
parallel with VACUUM FULL of assorted system catalogs.

For consistency I moved all the heap_open calls to the starts of their
functions, including a couple for which there was no actual bug.

Back-patch to 8.4 where foreigncmds.c was added.

Branch
------
REL8_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/3c96f5c647852d1c77f9854cf1f78dfb01af8631

Modified Files
--------------
src/backend/commands/foreigncmds.c | 31 ++++++++++++++-----------------
1 files changed, 14 insertions(+), 17 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2011-08-15 12:25:31 pgsql: Add "Reason code" prefix to internal SSI error messages
Previous Message Peter Eisentraut 2011-08-14 18:04:26 pgsql: Message style improvements