pgsql: Acquire properly session-level lock on new index in REINDEX CONC

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Acquire properly session-level lock on new index in REINDEX CONC
Date: 2019-10-23 06:06:01
Message-ID: E1iN9mT-0005ss-50@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Acquire properly session-level lock on new index in REINDEX CONCURRENTLY

In the first transaction run for REINDEX CONCURRENTLY, a thinko in the
existing logic caused two session locks to be taken on the old index,
causing the session lock on the newly-created index to be missed. This
made possible concurrent DDL commands (like ALTER INDEX) on the new
index while REINDEX CONCURRENTLY was processing from the point where the
first internal transaction committed.

This issue has been discovered while digging into another bug.

Author: Michael Paquier
Discussion: https://postgr.es/m/20191021074323.GB1869@paquier.xyz
Backpatch-through: 12

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7668d48477edc3bc8d6990ac3d3bd79e327e2719

Modified Files
--------------
src/backend/commands/indexcmds.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2019-10-23 22:06:41 pgsql: pg_upgrade: adjust error output to use new database list format
Previous Message Peter Eisentraut 2019-10-23 05:12:43 pgsql: Remove libpq-dist.rc