Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5d3500d

Browse files
committed
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
1 parent 508e84d commit 5d3500d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/backend/commands/indexcmds.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -2960,8 +2960,11 @@ ReindexRelationConcurrently(Oid relationOid, int options)
29602960
indexId,
29612961
concurrentName);
29622962

2963-
/* Now open the relation of the new index, a lock is also needed on it */
2964-
newIndexRel = index_open(indexId, ShareUpdateExclusiveLock);
2963+
/*
2964+
* Now open the relation of the new index, a session-level lock is
2965+
* also needed on it.
2966+
*/
2967+
newIndexRel = index_open(newIndexId, ShareUpdateExclusiveLock);
29652968

29662969
/*
29672970
* Save the list of OIDs and locks in private context

0 commit comments

Comments
 (0)