From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Manuel Rigger <rigger.manuel@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: REINDEX CONCURRENTLY unexpectedly fails
Date: Tue, 7 Jan 2020 17:33:23 +0200
Message-ID: <8f0bde7b-2d96-fb5c-cd0e-553694c1d376@iki.fi> (raw)
In-Reply-To: <20191223015956.GB34339@paquier.xyz>
References: <20191114080855.GG1910@paquier.xyz>
<3808.1573754033@sss.pgh.pa.us>
<20191115024512.GE1849@paquier.xyz>
<20191115025412.p3beiflrd6bx6wgf@alap3.anarazel.de>
<20191115032141.GH1849@paquier.xyz>
<20191115080706.GI1849@paquier.xyz>
<20191120013649.2xfr2dnznyjgluch@alap3.anarazel.de>
<20191120035408.GA4243@paquier.xyz>
<20191212213709.neopqccvdo724eha@alap3.anarazel.de>
<20191213034536.GD1942@paquier.xyz>
<20191223015956.GB34339@paquier.xyz>
On 23/12/2019 03:59, Michael Paquier wrote:
> +/*
> + * RelationSupportsConcurrentIndexing
> + *
> + * Check if a relation supports concurrent builds or not. This is
> + * used as a sanity check prior processing CREATE INDEX, DROP INDEX
> + * or REINDEX when using CONCURRENTLY.
> + */
> +bool
> +RelationSupportsConcurrentIndexing(char relpersistence)
> +{
> + /*
> + * Build indexes non-concurrently for temporary relations. Such
> + * relations only work with the session assigned to them, so they are
> + * not subject to concurrent concerns, and a concurrent build would
> + * cause issues with ON COMMIT actions triggered by the transactions
> + * of the concurrent build. A non-concurrent reindex is also more
> + * efficient in this case.
> + */
> + if (relpersistence == RELPERSISTENCE_TEMP)
> + return false;
> +
> + return true;
> +}
> +
The comment says "this is used as a sanity check". "Sanity check"
implies that it should never happen, but it is perfectly normal for it
to return false.
The caller in DefineIndex() calls RelationSupportsConcurrentIndexing()
only after choosing the lock mode. That's fine for temporary tables, but
if wouldn't work right if RelationSupportsConcurrentIndexing() started
to return false for some other tables. Maybe it would be clearer to just
check "relpersistence == RELPERSISTENCE_TEMP" directly in the callers,
and not have the RelationSupportsConcurrentIndexing() function.
The new text in drop_index.sgml talks about index creation, copy-pasted
from create_index.sgml.
- Heikki
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: hlinnaka@iki.fi, michael@paquier.xyz, andres@anarazel.de, tgl@sss.pgh.pa.us, rigger.manuel@gmail.com
Subject: Re: REINDEX CONCURRENTLY unexpectedly fails
In-Reply-To: <8f0bde7b-2d96-fb5c-cd0e-553694c1d376@iki.fi>
References: <20191114080855.GG1910@paquier.xyz> <3808.1573754033@sss.pgh.pa.us> <20191115024512.GE1849@paquier.xyz> <20191115025412.p3beiflrd6bx6wgf@alap3.anarazel.de> <20191115032141.GH1849@paquier.xyz> <20191115080706.GI1849@paquier.xyz> <20191120013649.2xfr2dnznyjgluch@alap3.anarazel.de> <20191120035408.GA4243@paquier.xyz> <20191212213709.neopqccvdo724eha@alap3.anarazel.de> <20191213034536.GD1942@paquier.xyz> <20191223015956.GB34339@paquier.xyz> <8f0bde7b-2d96-fb5c-cd0e-553694c1d376@iki.fi>
* 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