Re: REINDEX INDEX results in a crash for an index of pg_class since 9.6
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-30T18:27:41Z
Lists: pgsql-hackers
Hi, On 2019-04-30 14:05:50 -0400, Tom Lane wrote: > Andres Freund <andres@anarazel.de> writes: > > It's the lock-upgrade problem I theorized about > > upthread. ReindexIndex(), via RangeVarCallbackForReindexIndex(), takes a > > ShareLock on pg_class, and then goes on to upgrade to RowExclusiveLock > > in RelationSetNewRelfilenode(). But at that time another session > > obviously can already have the ShareLock and would also want to upgrade. > > Hmm. Note that this is totally independent of the deadlock mechanism > I reported in my last message on this thread. Yea :( > > I'm not sure it's worth fixing this. > > I am not sure it's even *possible* to fix all these cases. I think it's worth fixing the most common ones though. It sure sucks that a plain REINDEX TABLE pg_class; isn't safe to run. > Even if we could, it's out of scope for v12 let alone the back branches. Unfortunately agreed. It's possible we could come up with a fix to backpatch after maturing some, but certainly not before the release. > I think the only practical solution is to remove those reindex tests. > Even if we ran them in a script with no concurrent scripts, there'd > be risk of failures against autovacuum, I'm afraid. Not often, but > often enough to be annoying. > Possibly we could run them in a TAP test that configures a cluster > with autovac disabled? Hm. Would it be sufficient to instead move them to a non-concurrent test group, and stick a BEGIN; LOCK pg_class, ....; COMMIT; around it? I think that ought to make it safe against autovacuum, and theoretically there shouldn't be any overlapping pg_class/index updates that we'd need to wait for? This is a pretty finnicky area of the code, with obviously not enough test coverage. I'm inclined to remove them from the back branches, and try to get them working in master? Greetings, Andres Freund
Commits
-
Remove reindex_catalog test from test schedules.
- 5997a8f4d747 12.0 landed
- 70200d0d7402 9.4.22 landed
- 8439589bc7e7 9.5.17 landed
- 55eebb80005c 9.6.13 landed
- 443ca97956ee 10.8 landed
- 60c2951e1bab 11.3 landed
-
Remove RelationSetIndexList().
- f884dca4959f 12.0 landed
-
Fix reindexing of pg_class indexes some more.
- 5f8e84ff47ff 9.4.22 landed
- f912d7dec293 12.0 landed
- d18ef690509f 9.5.17 landed
- 727c155cfbfb 11.3 landed
- 2bb1adfacdf1 9.6.13 landed
- 18138066ff36 10.8 landed
-
Run catalog reindexing test from 3dbb317d32 serially, to avoid deadlocks.
- ad791802831e 10.8 landed
- 8e955f212089 9.6.13 landed
- 856bc0c612be 9.4.22 landed
- 809c9b48f4bd 12.0 landed
- 63c6a24ae4d6 11.3 landed
- 3630c6bfad94 9.5.17 landed
-
Fix potential assertion failure when reindexing a pg_class index.
- e7418f89f17a 9.4.22 landed
- 670a492c5f1b 9.5.17 landed
- 17126e0892cb 9.6.13 landed
- f495b65a5659 10.8 landed
- 14323493dd53 11.3 landed
- 3dbb317d32f4 12.0 landed
-
Fix several recently introduced issues around handling new relation forks.
- 5c1560606dc4 12.0 landed
-
Avoid VACUUM FULL altogether in initdb.
- 01e386a32554 9.6.0 cited
-
Introduce replication progress tracking infrastructure.
- 5aa2350426c4 9.5.0 cited
-
initdb: remove unnecessary VACUUM FULL
- ed7b3b3811c5 9.5.0 cited