Re: remove spurious CREATE INDEX CONCURRENTLY wait
James Coleman <jtc331@gmail.com>
From: James Coleman <jtc331@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>, Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-08-11T01:26:26Z
Lists: pgsql-hackers
On Mon, Aug 10, 2020 at 8:37 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Alvaro Herrera <alvherre@2ndquadrant.com> writes: > > To recap: currently, any CREATE INDEX CONCURRENTLY will wait for all > > other CICs running concurrently to finish, because they can't be > > distinguished amidst other old snapshots. We can change things by > > having CIC set a special flag in PGPROC (like PROC_IN_VACUUM) indicating > > that it's doing CIC; other CICs will see that flag and will know that > > they don't need to wait for those processes. With this, CIC on small > > tables don't have to wait for CIC on large tables to complete. > > Hm. +1 for improving this, if we can, but ... > > It seems clearly unsafe to ignore a CIC that is in active index-building; > a snapshot held for that purpose is just as real as any other. It *might* > be all right to ignore a CIC that is just waiting, but you haven't made > any argument in the patch comments as to why that's safe either. > (Moreover, at the points where we're just waiting, I don't think we have > a snapshot, so another CIC's WaitForOlderSnapshots shouldn't wait for us > anyway.) Why is a CIC in active index-building something we need to wait for? Wouldn't it fall under a similar kind of logic to the other snapshot types we can explicitly ignore? CIC can't be run in a manual transaction, so the snapshot it holds won't be used to perform arbitrary operations (i.e., the reason why a manual ANALYZE can't be ignored). > Actually, it doesn't look like you've touched the comments at all. > WaitForOlderSnapshots' header comment has a long explanation of why > it's safe to ignore certain processes. That certainly needs to be > updated by any patch that's going to change the rules. Agreed that the comment needs to be updated to discuss the (im)possibility of arbitrary operations within a snapshot held by CIC. James
Commits
-
Restore lock level to set vacuum flags
- 9aa91cb33b70 14.2 landed
- 0726c764bc4e 15.0 landed
-
Restore lock level to update statusFlags
- dcfff74fb166 14.0 landed
-
Avoid spurious waits in concurrent indexing
- c98763bf51bf 14.0 landed
-
Centralize logic for skipping useless ereport/elog calls.
- 789b938bf2b8 14.0 landed
-
Don't hold ProcArrayLock longer than needed in rare cases
- 450c8230b1f7 14.0 landed
-
Relax lock level for setting PGPROC->statusFlags
- 27838981be9d 14.0 landed
-
Rename PGPROC->vacuumFlags to statusFlags
- cd9c1b3e197a 14.0 landed
-
snapshot scalability: Move PGXACT->vacuumFlags to ProcGlobal->vacuumFlags.
- 5788e258bb26 14.0 cited
-
Allow an autovacuum worker to be interrupted automatically when it is found
- acac68b2bcae 8.3.0 cited