pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Miles Delahunty <miles.delahunty@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: can't drop table due to reference from orphaned temp function
Date: Sat, 19 Feb 2022 13:31:39 -0800
Message-ID: <20220219213139.2gpsrqwp7hlmn634@alap3.anarazel.de> (raw)
In-Reply-To: <20220219180002.6tubjq7iw7m52bgd@alap3.anarazel.de>
References: <CAOFAq3BU5Mf2TTvu8D9n_ZOoFAeQswuzk7yziAb7xuw_qyw5gw@mail.gmail.com>
	<20220219180002.6tubjq7iw7m52bgd@alap3.anarazel.de>

Hi,

On 2022-02-19 10:00:02 -0800, Andres Freund wrote:
> See backtrace below [1]. The same problem does *not* exist when starting to
> use the same temp schema in a new session (which drops the old contents
> first), which kind of explains why we've not previously noticed this.
>
> But even so, I'm surprised we haven't noticed this before.

Ah, there's a reason for that. In many cases we'll have a catalog snapshot
registered, which is enough for init_toast_snapshot(). But in Miles' example,
the object dropped just prior ends with catalog invalidations.

Proposed bugfix and test attached.

I think it's ok to backpatch the test. There might be a slight change in
output due to 618c16707a6d6e8f5c83ede2092975e4670201ad not being backpatched,
but that's OK I think.


I think it is dangerous that we return a cached catalog snapshot for things
like GetOldestSnapshot() unless they're also registered or active - we can't
rely on catalog snapshots to be present. Indeed, if we didn't, this bug would
have been found before, as some added assertions confirm.

I don't think we can just ignore the catalog snapshot though, it can be
registered in the future, so it actually is the oldest snapshot. But at least
we should assert that there's some snapshot registered/active. In the attached
patch I've added HaveRegisteredOrActiveSnapshot() and used that in
init_toast_snapshot().

Any better ideas?

Greetings,

Andres Freund

Attachments:

  v1-0001-Fix-temporary-object-cleanup-failing-due-to-toast.patch (text/x-diff, 0B) download

view thread (7+ messages)  latest in thread

Message-ID: <20220219213139.2gpsrqwp7hlmn634@alap3.anarazel.de>
Permalink:  ../20220219213139.2gpsrqwp7hlmn634@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20220219213139.2gpsrqwp7hlmn634@alap3.anarazel.de

 ·  · 

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-bugs@postgresql.org
  Cc: andres@anarazel.de, miles.delahunty@gmail.com, tgl@sss.pgh.pa.us, robertmhaas@gmail.com
  Subject: Re: can't drop table due to reference from orphaned temp function
  In-Reply-To: <20220219213139.2gpsrqwp7hlmn634@alap3.anarazel.de>
  References: <CAOFAq3BU5Mf2TTvu8D9n_ZOoFAeQswuzk7yziAb7xuw_qyw5gw@mail.gmail.com> <20220219180002.6tubjq7iw7m52bgd@alap3.anarazel.de> <20220219213139.2gpsrqwp7hlmn634@alap3.anarazel.de>

* 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