pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: gabrielle <gorthx@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Unable to drop invalid TOAST indexes
Date: Sun, 12 Sep 2021 20:21:52 +0200
Message-ID: <5248678bf085a9c1593b46c8a440ec8dff0a8faf.camel@cybertec.at> (raw)
In-Reply-To: <CAHRs-_c93COBSL+ESer5vadGf4rb6XZ4t6hM_yF+xwz3Ae0rGA@mail.gmail.com>
References: <CAHRs-_c93COBSL+ESer5vadGf4rb6XZ4t6hM_yF+xwz3Ae0rGA@mail.gmail.com>

On Fri, 2021-09-10 at 17:50 -0700, gabrielle wrote:
> I ran into an interesting situation last week.
> 
> Discovered on RDS Postgres version 13.
> Replicated on community Postgres version 13.
> 
> A client wanted us to drop some invalid indexes, some of which turned out to be invalid indexes on TOAST tables.
> 
> We don't know for sure how their database got this way; we suspect a failed 'REINDEX DATABASE CONCURRENTLY', possibly more than one.
> 
> Attempts to drop the invalid index fail like so:
>     testy=> drop index CONCURRENTLY pg_toast.pg_toast_14199_index_ccnew;
>     ERROR:  permission denied for schema pg_toast
> 
> This fails even when I'm logged in as the owner of the toast table's parent table;  I have to assume superuser privileges in order to drop them.
> 
> On a hosted environment, this means a user could create an invalid index that they can't drop without provider intervention.
> 
> Is this expected behavior?

In order to rebuild the TOAST index on "sometable", run

  REINDEX TABLE CONCURRENTLY sometable;

As the documentation says: "If the table has a secondary “TOAST” table, that is reindexed as well."

You cannot drop the TOASE index, as that is required for PostgreSQL to function.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (2+ messages)

Message-ID: <5248678bf085a9c1593b46c8a440ec8dff0a8faf.camel@cybertec.at>
Permalink:  ../5248678bf085a9c1593b46c8a440ec8dff0a8faf.camel@cybertec.at/
Also on:    postgresql.org/message-id/5248678bf085a9c1593b46c8a440ec8dff0a8faf.camel@cybertec.at

 · 

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-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, gorthx@gmail.com
  Subject: Re: Unable to drop invalid TOAST indexes
  In-Reply-To: <5248678bf085a9c1593b46c8a440ec8dff0a8faf.camel@cybertec.at>
  References: <CAHRs-_c93COBSL+ESer5vadGf4rb6XZ4t6hM_yF+xwz3Ae0rGA@mail.gmail.com> <5248678bf085a9c1593b46c8a440ec8dff0a8faf.camel@cybertec.at>

* 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