aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c57
1 files changed, 17 insertions, 40 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7aaa3fb802f..5d748914f90 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -131,14 +131,6 @@ bool criticalSharedRelcachesBuilt = false;
static long relcacheInvalsReceived = 0L;
/*
- * This list remembers the OIDs of the non-shared relations cached in the
- * database's local relcache init file. Note that there is no corresponding
- * list for the shared relcache init file, for reasons explained in the
- * comments for RelationCacheInitFileRemove.
- */
-static List *initFileRelationIds = NIL;
-
-/*
* This flag lets us optimize away work in AtEO(Sub)Xact_RelationCache().
*/
static bool need_eoxact_work = false;
@@ -3083,9 +3075,6 @@ RelationCacheInitializePhase3(void)
*/
InitCatalogCachePhase2();
- /* reset initFileRelationIds list; we'll fill it during write */
- initFileRelationIds = NIL;
-
/* now write the files */
write_relcache_init_file(true);
write_relcache_init_file(false);
@@ -4248,10 +4237,6 @@ load_relcache_init_file(bool shared)
for (relno = 0; relno < num_rels; relno++)
{
RelationCacheInsert(rels[relno]);
- /* also make a list of their OIDs, for RelationIdIsInInitFile */
- if (!shared)
- initFileRelationIds = lcons_oid(RelationGetRelid(rels[relno]),
- initFileRelationIds);
}
pfree(rels);
@@ -4288,10 +4273,16 @@ write_relcache_init_file(bool shared)
int magic;
HASH_SEQ_STATUS status;
RelIdCacheEnt *idhentry;
- MemoryContext oldcxt;
int i;
/*
+ * If we have already received any relcache inval events, there's no
+ * chance of succeeding so we may as well skip the whole thing.
+ */
+ if (relcacheInvalsReceived != 0L)
+ return;
+
+ /*
* We must write a temporary file and rename it into place. Otherwise,
* another backend starting at about the same time might crash trying to
* read the partially-complete file.
@@ -4350,6 +4341,16 @@ write_relcache_init_file(bool shared)
if (relform->relisshared != shared)
continue;
+ /*
+ * Ignore if not supposed to be in init file. We can allow any shared
+ * relation that's been loaded so far to be in the shared init file,
+ * but unshared relations must be used for catalog caches. (Note: if
+ * you want to change the criterion for rels to be kept in the init
+ * file, see also inval.c.)
+ */
+ if (!shared && !RelationSupportsSysCache(RelationGetRelid(rel)))
+ continue;
+
/* first write the relcache entry proper */
write_item(rel, sizeof(RelationData), fp);
@@ -4406,15 +4407,6 @@ write_relcache_init_file(bool shared)
relform->relnatts * sizeof(int16),
fp);
}
-
- /* also make a list of their OIDs, for RelationIdIsInInitFile */
- if (!shared)
- {
- oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
- initFileRelationIds = lcons_oid(RelationGetRelid(rel),
- initFileRelationIds);
- MemoryContextSwitchTo(oldcxt);
- }
}
if (FreeFile(fp))
@@ -4474,21 +4466,6 @@ write_item(const void *data, Size len, FILE *fp)
}
/*
- * Detect whether a given relation (identified by OID) is one of the ones
- * we store in the local relcache init file.
- *
- * Note that we effectively assume that all backends running in a database
- * would choose to store the same set of relations in the init file;
- * otherwise there are cases where we'd fail to detect the need for an init
- * file invalidation. This does not seem likely to be a problem in practice.
- */
-bool
-RelationIdIsInInitFile(Oid relationId)
-{
- return list_member_oid(initFileRelationIds, relationId);
-}
-
-/*
* Invalidate (remove) the init file during commit of a transaction that
* changed one or more of the relation cache entries that are kept in the
* local init file.