pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid possible crash while finishing up a heap rewrite.
Date: Tue, 23 Mar 2021 15:24:24 +0000
Message-ID: <E1lOitM-00064z-6o@gemulon.postgresql.org> (raw)

Avoid possible crash while finishing up a heap rewrite.

end_heap_rewrite was not careful to ensure that the target relation
is open at the smgr level before performing its final smgrimmedsync.
In ordinary cases this is no problem, because it would have been
opened earlier during the rewrite.  However a crash can be reproduced
by re-clustering an empty table with CLOBBER_CACHE_ALWAYS enabled.

Although that exact scenario does not crash in v13, I think that's
a chance result of unrelated planner changes, and the problem is
likely still reachable with other test cases.  The true proximate
cause of this failure is commit c6b92041d, which replaced a call to
heap_sync (which was careful about opening smgr) with a direct call
to smgrimmedsync.  Hence, back-patch to v13.

Amul Sul, per report from Neha Sharma; cosmetic changes
and test case by me.

Discussion: https://postgr.es/m/CANiYTQsU7yMFpQYnv=BrcRVqK_3U3mtAzAsJCaqtzsDHfsUbdQ@mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d4791ac35cb1d7417ea3cff6cc604623463ef0ea

Modified Files
--------------
src/backend/access/heap/rewriteheap.c | 6 +++++-
src/test/regress/expected/cluster.out | 5 +++++
src/test/regress/sql/cluster.sql      | 6 ++++++
3 files changed, 16 insertions(+), 1 deletion(-)



view thread (2+ messages)

Message-ID: <E1lOitM-00064z-6o@gemulon.postgresql.org>
Permalink:  ../E1lOitM-00064z-6o@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lOitM-00064z-6o@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid possible crash while finishing up a heap rewrite.
  In-Reply-To: <E1lOitM-00064z-6o@gemulon.postgresql.org>
  References: <E1lOitM-00064z-6o@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox