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

Commit08acba5

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 parent1acab12 commit08acba5

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
@@ -3632,18 +3632,10 @@ validate_index_heapscan(Relation heapRelation,
36323632
* index_set_state_flags - adjust pg_index state flags
36333633
*
36343634
* This is used during CREATE/DROP INDEX CONCURRENTLY to adjust the pg_index
3635-
* flags that denote the index's state. Because the update is not
3636-
* transactional and will not roll back on error, this must only be used as
3637-
* the last step in a transaction that has not made any transactional catalog
3638-
* updates!
3635+
* flags that denote the index's state.
36393636
*
3640-
* Note thatheap_inplace_update does senda cacheinval message for the
3637+
* Note thatCatalogTupleUpdate() sendsa cacheinvalidation message for the
36413638
* tuple, so other sessions will hear about the update as soon as we commit.
3642-
*
3643-
* NB: In releases prior to PostgreSQL 9.4, the use of a non-transactional
3644-
* update here would have been unsafe; now that MVCC rules apply even for
3645-
* system catalog scans, we could potentially use a transactional update here
3646-
* instead.
36473639
*/
36483640
void
36493641
index_set_state_flags(OidindexId,IndexStateFlagsActionaction)
@@ -3652,9 +3644,6 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
36523644
HeapTupleindexTuple;
36533645
Form_pg_indexindexForm;
36543646

3655-
/* Assert that current xact hasn't done any transactional updates */
3656-
Assert(GetTopTransactionIdIfAny()==InvalidTransactionId);
3657-
36583647
/* Open pg_index and fetch a writable copy of the index's tuple */
36593648
pg_index=heap_open(IndexRelationId,RowExclusiveLock);
36603649

@@ -3713,8 +3702,8 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
37133702
break;
37143703
}
37153704

3716-
/* ... andwrite it back in-place */
3717-
heap_inplace_update(pg_index,indexTuple);
3705+
/* ... andupdate it */
3706+
CatalogTupleUpdate(pg_index,&indexTuple->t_self,indexTuple);
37183707

37193708
heap_close(pg_index,RowExclusiveLock);
37203709
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp