Incorrect relation locked at beginning of REINDEX CONCURRENTLY - Mailing list pgsql-hackers

From Michael Paquier
Subject Incorrect relation locked at beginning of REINDEX CONCURRENTLY
Date
Msg-id 20191021074323.GB1869@paquier.xyz
Whole thread Raw
List pgsql-hackers
Hi all,

While digging into the issues reported lately about REINDEX
CONCURRENTLY, I have bumped into the following, independent, issue:
/* Now open the relation of the new index, a lock is also needed on it */
newIndexRel = index_open(indexId, ShareUpdateExclusiveLock)

In this code path, indexId is the OID od the old index copied, and
newIndexId is the OID of the new index created.  So that's clearly
incorrect, and the comment even says the intention.  This causes for
example the same session lock to be taken twice on the old index, with
the new index remaining unprotected.

Any objections if I fix this issue as per the attached?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Thunder
Date:
Subject: [BUG] standby node can not provide service even it replays all logfiles
Next
From: Thunder
Date:
Subject: Re:[BUG] standby node can not provide service even it replays alllog files