summaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/inval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/cache/inval.c')
-rw-r--r--src/backend/utils/cache/inval.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 9d21ee6b07f..f0c26120873 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -515,10 +515,12 @@ RegisterRelcacheInvalidation(Oid dbId, Oid relId)
(void) GetCurrentCommandId(true);
/*
- * If the relation being invalidated is one of those cached in the local
- * relcache init file, mark that we need to zap that file at commit.
+ * If the relation being invalidated is one of those cached in a relcache
+ * init file, mark that we need to zap that file at commit. For simplicity
+ * invalidations for a specific database always invalidate the shared file
+ * as well.
*/
- if (OidIsValid(dbId) && RelationIdIsInInitFile(relId))
+ if (RelationIdIsInInitFile(relId))
transInvalInfo->RelcacheInitFileInval = true;
}
@@ -870,18 +872,26 @@ ProcessCommittedInvalidationMessages(SharedInvalidationMessage *msgs,
if (RelcacheInitFileInval)
{
+ elog(trace_recovery(DEBUG4), "removing relcache init files for database %u",
+ dbid);
+
/*
- * RelationCacheInitFilePreInvalidate requires DatabasePath to be set,
- * but we should not use SetDatabasePath during recovery, since it is
+ * RelationCacheInitFilePreInvalidate, when the invalidation message
+ * is for a specific database, requires DatabasePath to be set, but we
+ * should not use SetDatabasePath during recovery, since it is
* intended to be used only once by normal backends. Hence, a quick
* hack: set DatabasePath directly then unset after use.
*/
- DatabasePath = GetDatabasePath(dbid, tsid);
- elog(trace_recovery(DEBUG4), "removing relcache init file in \"%s\"",
- DatabasePath);
+ if (OidIsValid(dbid))
+ DatabasePath = GetDatabasePath(dbid, tsid);
+
RelationCacheInitFilePreInvalidate();
- pfree(DatabasePath);
- DatabasePath = NULL;
+
+ if (OidIsValid(dbid))
+ {
+ pfree(DatabasePath);
+ DatabasePath = NULL;
+ }
}
SendSharedInvalidMessages(msgs, nmsgs);