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

Commitacb60ed

Browse files
committed
Make index_set_state_flags() transactional
3c84046 is the original commit that introduced index_set_state_flags(),where the presence of SnapshotNow made necessary the use of an in-placeupdate. SnapshotNow has been removed in813fb03, so there is no actualreasons to not make this operation transactional.As reported by Andrey, it is possible to trigger the assertion of thisroutine expecting no transactional updates when switching the pg_indexstate flags, using a predicate mark as immutable but calling stable orvolatile functions.83158f7 has been around for a couple of months onHEAD now with no issues found related to it, so it looks safe enough fora backpatch.Reported-by: Andrey LepikhovAuthor: Michael PaquierReviewed-by: Anastasia LubennikovaDiscussion:https://postgr.es/m/20200903080440.GA8559@paquier.xyzDiscussion:https://postgr.es/m/9b905019-5297-7372-0ad2-e1a4bb66a719@postgrespro.ruBackpatch-through: 9.6
1 parent2d09448 commitacb60ed

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

‎src/backend/catalog/index.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,18 +3375,10 @@ validate_index_callback(ItemPointer itemptr, void *opaque)
33753375
* index_set_state_flags - adjust pg_index state flags
33763376
*
33773377
* This is used during CREATE/DROP INDEX CONCURRENTLY to adjust the pg_index
3378-
* flags that denote the index's state. Because the update is not
3379-
* transactional and will not roll back on error, this must only be used as
3380-
* the last step in a transaction that has not made any transactional catalog
3381-
* updates!
3378+
* flags that denote the index's state.
33823379
*
3383-
* Note thatheap_inplace_update does senda cacheinval message for the
3380+
* Note thatCatalogTupleUpdate() sendsa cacheinvalidation message for the
33843381
* tuple, so other sessions will hear about the update as soon as we commit.
3385-
*
3386-
* NB: In releases prior to PostgreSQL 9.4, the use of a non-transactional
3387-
* update here would have been unsafe; now that MVCC rules apply even for
3388-
* system catalog scans, we could potentially use a transactional update here
3389-
* instead.
33903382
*/
33913383
void
33923384
index_set_state_flags(OidindexId,IndexStateFlagsActionaction)
@@ -3395,9 +3387,6 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
33953387
HeapTupleindexTuple;
33963388
Form_pg_indexindexForm;
33973389

3398-
/* Assert that current xact hasn't done any transactional updates */
3399-
Assert(GetTopTransactionIdIfAny()==InvalidTransactionId);
3400-
34013390
/* Open pg_index and fetch a writable copy of the index's tuple */
34023391
pg_index=table_open(IndexRelationId,RowExclusiveLock);
34033392

@@ -3456,8 +3445,8 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
34563445
break;
34573446
}
34583447

3459-
/* ... andwrite it back in-place */
3460-
heap_inplace_update(pg_index,indexTuple);
3448+
/* ... andupdate it */
3449+
CatalogTupleUpdate(pg_index,&indexTuple->t_self,indexTuple);
34613450

34623451
table_close(pg_index,RowExclusiveLock);
34633452
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp