> The attached patch takes a ShareUpdateExclusiveLock lock on the index in > order to clean the pending list.
Does it take a lock on the table also? Because if not ...
There must be some kind of lock held on the table already (either RowExclusive at least for user backends or ShareRowExclusive for vacuum backends), but I don't do anything in this patch with it.
> One potential problem is how it will interact with "create index > concurrently".
... then I don't understand how you could have a problem here. Surely no pending list cleanup can happen concurrently with the index being created?
While grepping through the code looking for precedent, I noticed that "create index concurrently" takes a ShareUpdateExclusiveLock on both table and index. I don't know why it needs one on the index, I didn't investigate it thoroughly.
During the last stage of the "create index concurrently", inserters and updaters are obliged to maintain the index even though they can't use it yet. So that would mean adding to the pending list, which might get big enough to need cleaning.