Re: REINDEX CONCURRENTLY unexpectedly fails
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Manuel Rigger <rigger.manuel@gmail.com>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2019-11-15T02:54:12Z
Lists: pgsql-bugs
Hi, On 2019-11-15 11:45:12 +0900, Michael Paquier wrote: > On Thu, Nov 14, 2019 at 12:53:53PM -0500, Tom Lane wrote: > > I don't find that very convincing. If there's a reason to throw > > error for global temporary tables, let's do it for that case, > > but that's no reason to make the user-visible behavior overcomplex > > for other cases. It might well be that we can handle global temp > > tables the same way anyway (ie, just do a not-CONCURRENTLY reindex > > on the session's private instance of the table). > > Well, there is also the argument of consistency. What should we do if > trying to reindex concurrently a database or a schema and that the > database or the schema include both temporary and non-temporary > tables? We cannot ignore CONCURRENTLY in this case for all the > relations if there is at least one temporary table. It could be as > well surprising to skip only a portion of temporary relations (these > with on-commit actions and issue a WARNING for each one of them, still > that would be more consistent with the treatment we do for system > catalogs in ReindexMultipleTables(). Who said anything about skipping? What I was talking about was to execute a non-concurrent truncate for temp tables? Given that there never may be any relevant concurrency, and given that a non-concurrent index build is considerably cheaper, that's a nice optimization. As well as fixing the bug at hand? I think it'd be really user hostile if ReindexMultipleTables() suddenly started to error out if there were any temp tables. That clearly can't be an option. > An extra solution I can think of is to not skip temporary tables with > on-commit actions, but just fallback to the non-concurrent path in > ReindexMultipleTables when reindexing each relation for any temporary > tables processed (all of them, and not just these with on-commit > actions actually). Did you actually read the sub-thread before replying? That's literally what we are discussing: On 2019-11-13 11:45:34 -0500, Tom Lane wrote: > Andres Freund <andres@anarazel.de> writes: > > I wonder if we instead ought to just ignore the CONCURRENTLY when > > targetting a temp table? That'd be a correct optimization for temp > > tables, and would fix the issue at hand... > > Oh, I like that idea. Keeps applications from having to think > about this. That's the email you directly replied to. Greetings, Andres Freund
Commits
-
Fix concurrent indexing operations with temporary tables
- d76652edc56f 9.4.26 landed
- c39f45598177 9.5.21 landed
- ef33edeb5835 9.6.17 landed
- 9055344b495f 10.12 landed
- 5b4b07fa9ac3 11.7 landed
- 817a1b88ac66 12.2 landed
- a904abe2e284 13.0 landed