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

Commitb85a9d0

Browse files
committed
Avoid looping over all type cache entries in TypeCacheRelCallback()
Currently, when a single relcache entry gets invalidated,TypeCacheRelCallback() has to loop over all type cache entries to findappropriate typentry to invalidate. Unfortunately, using the syscache hereis impossible, because this callback could be called outside a transactionand this makes impossible catalog lookups. This is why present commitintroduces RelIdToTypeIdCacheHash to map relation OID to its composite typeOID.We are keeping RelIdToTypeIdCacheHash entry while corresponding type cacheentry have something to clean. Therefore, RelIdToTypeIdCacheHash shouldn'tget bloat in the case of temporary tables flood.There are many places in lookup_type_cache() where syscache invalidation,user interruption, or even error could occur. In order to handle this, wekeep an array of in-progress type cache entries. In the case oflookup_type_cache() interruption this array is processed to keepRelIdToTypeIdCacheHash in a consistent state.Discussion:https://postgr.es/m/5812a6e5-68ae-4d84-9d85-b443176966a1%40sigaev.ruAuthor: Teodor SigaevReviewed-by: Aleksander Alekseev, Tom Lane, Michael Paquier, Roman ZharkovReviewed-by: Andrei Lepikhov, Pavel Borisov, Jian He, Alexander LakhinReviewed-by: Artur Zakirov
1 parentc1500a1 commitb85a9d0

File tree

11 files changed

+433
-46
lines changed

11 files changed

+433
-46
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include"utils/snapmgr.h"
7171
#include"utils/timeout.h"
7272
#include"utils/timestamp.h"
73+
#include"utils/typcache.h"
7374

7475
/*
7576
*User-tweakable parameters
@@ -2407,6 +2408,9 @@ CommitTransaction(void)
24072408
/* Clean up the relation cache */
24082409
AtEOXact_RelationCache(true);
24092410

2411+
/* Clean up the type cache */
2412+
AtEOXact_TypeCache();
2413+
24102414
/*
24112415
* Make catalog changes visible to all backends. This has to happen after
24122416
* relcache references are dropped (see comments for
@@ -2709,6 +2713,9 @@ PrepareTransaction(void)
27092713
/* Clean up the relation cache */
27102714
AtEOXact_RelationCache(true);
27112715

2716+
/* Clean up the type cache */
2717+
AtEOXact_TypeCache();
2718+
27122719
/* notify doesn't need a postprepare call */
27132720

27142721
PostPrepare_PgStat();
@@ -2951,6 +2958,7 @@ AbortTransaction(void)
29512958
false, true);
29522959
AtEOXact_Buffers(false);
29532960
AtEOXact_RelationCache(false);
2961+
AtEOXact_TypeCache();
29542962
AtEOXact_Inval(false);
29552963
AtEOXact_MultiXact();
29562964
ResourceOwnerRelease(TopTransactionResourceOwner,
@@ -5153,6 +5161,7 @@ CommitSubTransaction(void)
51535161
true, false);
51545162
AtEOSubXact_RelationCache(true,s->subTransactionId,
51555163
s->parent->subTransactionId);
5164+
AtEOSubXact_TypeCache();
51565165
AtEOSubXact_Inval(true);
51575166
AtSubCommit_smgr();
51585167

@@ -5328,6 +5337,7 @@ AbortSubTransaction(void)
53285337

53295338
AtEOSubXact_RelationCache(false,s->subTransactionId,
53305339
s->parent->subTransactionId);
5340+
AtEOSubXact_TypeCache();
53315341
AtEOSubXact_Inval(false);
53325342
ResourceOwnerRelease(s->curTransactionOwner,
53335343
RESOURCE_RELEASE_LOCKS,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp