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

Commit9ad45c1

Browse files
committed
Fix race condition in enum value comparisons.
When (re) loading the typcache comparison cache for an enum type's values,use an up-to-date MVCC snapshot, not the transaction's existing snapshot.This avoids problems if we encounter an enum OID that was created since ourtransaction started. Per report from Andres Freund and diagnosis by RobertHaas.To ensure this is safe even if enum comparison manages to get invokedbefore we've set a transaction snapshot, tweak GetLatestSnapshot toredirect to GetTransactionSnapshot instead of throwing error whenFirstSnapshotSet is false. The existing uses of GetLatestSnapshot (inri_triggers.c) don't care since they couldn't be invoked except in atransaction that's already done some work --- but it seems just conceivablethat this might not be true of enums, especially if we ever choose to useenums in system catalogs.Note that the comparable coding in enum_endpoint and enum_range_internalremains GetTransactionSnapshot; this is perhaps debatable, but if wechanged it those functions would have to be marked volatile, which doesn'tseem attractive.Back-patch to 9.1 where ALTER TYPE ADD VALUE was added.
1 parent39bfc94 commit9ad45c1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

‎src/backend/utils/cache/typcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ load_enum_cache_data(TypeCacheEntry *tcache)
10891089
enum_rel=heap_open(EnumRelationId,AccessShareLock);
10901090
enum_scan=systable_beginscan(enum_rel,
10911091
EnumTypIdLabelIndexId,
1092-
true,GetTransactionSnapshot(),
1092+
true,GetLatestSnapshot(),
10931093
1,&skey);
10941094

10951095
while (HeapTupleIsValid(enum_tuple=systable_getnext(enum_scan)))

‎src/backend/utils/time/snapmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ GetTransactionSnapshot(void)
196196
Snapshot
197197
GetLatestSnapshot(void)
198198
{
199-
/*Should not befirst call in transaction */
199+
/*Iffirst call in transaction, go ahead and set the xact snapshot */
200200
if (!FirstSnapshotSet)
201-
elog(ERROR,"no snapshot has been set");
201+
returnGetTransactionSnapshot();
202202

203203
SecondarySnapshot=GetSnapshotData(&SecondarySnapshotData);
204204

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp