pgsql: In rebuild_relation(), don't access an already-closed relcache e

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: In rebuild_relation(), don't access an already-closed relcache e
Date: 2017-03-04 21:09:50
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

In rebuild_relation(), don't access an already-closed relcache entry.

This reliably fails with -DRELCACHE_FORCE_RELEASE, as reported by
Andrew Dunstan, and could sometimes fail in normal operation, resulting
in a wrong persistence value being used for the transient table.
It's not immediately clear to me what effects that might have beyond
the risk of a crash while accessing OldHeap->rd_rel->relpersistence,
but it's probably not good.

Bug introduced by commit f41872d0c, and made substantially worse by
commit 85b506bbf, which added a second such access significantly
later than the heap_close. I doubt the first reference could fail
in a production scenario, but the second one definitely could.

Discussion: https://postgr.es/m/[email protected]

Branch
------
REL9_6_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/68f7b91e509d9ac95a376805df22bc9b51e71255

Modified Files
--------------
src/backend/commands/cluster.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Simon Riggs 2017-03-06 10:24:22 pgsql: Allow partitioned tables to be dropped without CASCADE
Previous Message Peter Eisentraut 2017-03-04 19:48:51 pgsql: pg_dump: Fix ordering