Incorrect relation locked at beginning of REINDEX CONCURRENTLY

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Incorrect relation locked at beginning of REINDEX CONCURRENTLY
Date: 2019-10-21 07:43:23
Message-ID: 20191021074323.GB1869@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
reindex-conc-lock.patch text/x-diff 699 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Thunder 2019-10-21 08:12:46 Re:[BUG] standby node can not provide service even it replays all log files
Previous Message Thunder 2019-10-21 07:40:24 [BUG] standby node can not provide service even it replays all log files