Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9511fb3

Browse files
committed
Reset indisreplident for an invalid index in DROP INDEX CONCURRENTLY
A failure when dropping concurrently an index used in a replica identitycould leave in pg_index an index marked as !indisvalid andindisreplident. Reindexing this index would switch back indisvalid totrue, and if the replica identity of the parent relation was switched touse a different index, it would be possible to finish with more than oneindex marked as indisreplident. If that were to happen, this could messup with the relation cache as an incorrect index could be used for thereplica identity.Indexes marked as invalid are discarded as candidates for the replicaidentity, as of RelationGetIndexList(), so similarly to what is donewith indisclustered, resetting indisreplident when the index is markedas invalid keeps things consistent. REINDEX CONCURRENTLY's swappingalready resets the flag for the old index, while the new index inheritsthe value of the old index to-be-dropped, so only DROP INDEX was anissue.Even if this is a bug, the sequence able to reproduce a problem requiresa failure while running DROP INDEX CONCURRENTLY, something unlikelygoing to happen in the field, so no backpatch is done.Author: Michael PaquierReviewed-by: Dmitry DolgovDiscussion:https://postgr.es/m/20200827025721.GN2017@paquier.xyz
1 parent7a1cd52 commit9511fb3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎src/backend/catalog/index.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,6 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
15121512

15131513
/* Preserve indisreplident in the new index */
15141514
newIndexForm->indisreplident=oldIndexForm->indisreplident;
1515-
oldIndexForm->indisreplident= false;
15161515

15171516
/* Preserve indisclustered in the new index */
15181517
newIndexForm->indisclustered=oldIndexForm->indisclustered;
@@ -1524,6 +1523,7 @@ index_concurrently_swap(Oid newIndexId, Oid oldIndexId, const char *oldName)
15241523
newIndexForm->indisvalid= true;
15251524
oldIndexForm->indisvalid= false;
15261525
oldIndexForm->indisclustered= false;
1526+
oldIndexForm->indisreplident= false;
15271527

15281528
CatalogTupleUpdate(pg_index,&oldIndexTuple->t_self,oldIndexTuple);
15291529
CatalogTupleUpdate(pg_index,&newIndexTuple->t_self,newIndexTuple);
@@ -3349,10 +3349,13 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
33493349
* CONCURRENTLY that failed partway through.)
33503350
*
33513351
* Note: the CLUSTER logic assumes that indisclustered cannot be
3352-
* set on any invalid index, so clear that flag too.
3352+
* set on any invalid index, so clear that flag too. Similarly,
3353+
* ALTER TABLE assumes that indisreplident cannot be set for
3354+
* invalid indexes.
33533355
*/
33543356
indexForm->indisvalid= false;
33553357
indexForm->indisclustered= false;
3358+
indexForm->indisreplident= false;
33563359
break;
33573360
caseINDEX_DROP_SET_DEAD:
33583361

@@ -3364,6 +3367,8 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
33643367
* the index at all.
33653368
*/
33663369
Assert(!indexForm->indisvalid);
3370+
Assert(!indexForm->indisclustered);
3371+
Assert(!indexForm->indisreplident);
33673372
indexForm->indisready= false;
33683373
indexForm->indislive= false;
33693374
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp