Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
emelsimsek committed Aug 21, 2023
1 parent c0ea89a commit 7d80c17
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions src/backend/distributed/metadata/metadata_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2192,19 +2192,22 @@ CitusHasBeenLoaded(void)
*/
Assert(!(MetadataCache.extensionLoaded && MetadataCache.extensionNotLoaded));


if (creating_extension)
{
Oid citusExtensionOid = get_extension_oid("citus", true);

if (CurrentExtensionObject == citusExtensionOid)
{
return false;
}
}

/*
* MetadataCache.extensionLoaded = false
* MetadataCache.extensionNotLoaded = false
* means that the cache is invalid. Reevaluate the flags.
*/

Oid citusExtensionOid = get_extension_oid("citus", true);

if (creating_extension && (CurrentExtensionObject == citusExtensionOid))
{
return false;
}

if (!MetadataCache.extensionLoaded && !MetadataCache.extensionNotLoaded)
{
/*
Expand Down Expand Up @@ -4774,22 +4777,6 @@ InvalidateDistRelationCacheCallback(Datum argument, Oid relationId)
InvalidateCitusTableCacheEntrySlot(cacheSlot);
}

/*
* If pg_dist_partition is being invalidated drop all state
* This happens pretty rarely, but most importantly happens during
* DROP EXTENSION citus; This isn't the only time when this happens
* though, it can happen for multiple other reasons, such as an
* autovacuum running ANALYZE on pg_dist_partition. Such an ANALYZE
* wouldn't really need a full Metadata cache invalidation, but we
* don't know how to differentiate between DROP EXTENSION and ANALYZE.
* So for now we simply drop it in both cases and take the slight
* temporary performance hit.
*/
if (relationId == MetadataCache.distPartitionRelationId)
{
InvalidateMetadataSystemCache();
}

if (relationId == MetadataCache.distObjectRelationId)
{
InvalidateDistObjectCache();
Expand Down

0 comments on commit 7d80c17

Please sign in to comment.