Re: remove spurious CREATE INDEX CONCURRENTLY wait
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>, James Coleman <jtc331@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-11-10T01:28:26Z
Lists: pgsql-hackers
On Mon, Nov 09, 2020 at 04:47:43PM +0100, Dmitry Dolgov wrote: > > On Tue, Nov 03, 2020 at 07:14:47PM +0100, Dmitry Dolgov wrote: > > > On Thu, Aug 20, 2020 at 03:11:19PM +0900, Michael Paquier wrote: > > > On Wed, Aug 19, 2020 at 02:16:46PM -0400, Alvaro Herrera wrote: > > > > I did not set the flag in REINDEX CONCURRENTLY, but as I understand it > > > > can be done too, since in essence it's the same thing as a CIC from a > > > > snapshot management point of view. > > > > > > Yes, I see no problems for REINDEX CONCURRENTLY as well as long as > > > there are no predicates and expressions involved. The transactions > > > that should be patched are all started in ReindexRelationConcurrently. > > > The transaction of index_concurrently_swap() cannot set up that > > > though. Only thing to be careful is to make sure that safe_flag is > > > correct depending on the list of indexes worked on. > > > > Hi, > > > > After looking through the thread and reading the patch it seems good, > > and there are only few minor questions: > > > > * Doing the same for REINDEX CONCURRENTLY, which does make sense. In > > fact it's already mentioned in the commentaries as done, which a bit > > confusing. > > Just to give it a shot, would the attached change be enough? Could it be possible to rename vacuumFlags to statusFlags first? I did not see any objection to do this suggestion. > + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); > + MyProc->vacuumFlags |= PROC_IN_SAFE_IC; > + ProcGlobal->vacuumFlags[MyProc->pgxactoff] = MyProc->vacuumFlags; > + LWLockRelease(ProcArrayLock); I can't help noticing that you are repeating the same code pattern eight times. I think that this should be in its own routine, and that we had better document that this should be called just after starting a transaction, with an assertion enforcing that. -- Michael
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