From e87bc774d7f3ece9e11a49d502c1e04cb2ffe2c9 Mon Sep 17 00:00:00 2001 From: Matvey Arye Date: Fri, 31 Mar 2017 07:41:34 -0400 Subject: [PATCH] Fix logic for when entire cache is invalidated Sometimes postgres wants to invalidate the entire cache. In this case it send a cache invalidation message with relid == InvalidOid. This should invalidate all the caches. Previously, it did not effect the cache of the extension state. This fixes that problem and creates one cache reset code path for both extension dropping and whole-cache reset, cleaning up some of the logic in the process. --- src/cache_invalidate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cache_invalidate.c b/src/cache_invalidate.c index e5397b737..e65775338 100644 --- a/src/cache_invalidate.c +++ b/src/cache_invalidate.c @@ -49,21 +49,21 @@ inval_cache_callback(Datum arg, Oid relid) if (!extension_is_loaded()) return; - if (extension_is_being_dropped(relid)) + if (!OidIsValid(relid) || extension_is_being_dropped(relid)) { - /* Extension was dropped. Reset state. */ + /* Extension was dropped or entire cache invalidated. Reset state. */ hypertable_cache_invalidate_callback(); chunk_cache_invalidate_callback(); extension_reset(); return; } - if (!OidIsValid(relid) || relid == catalog_get_cache_proxy_id(catalog, CACHE_TYPE_HYPERTABLE)) + if (relid == catalog_get_cache_proxy_id(catalog, CACHE_TYPE_HYPERTABLE)) { hypertable_cache_invalidate_callback(); } - if (!OidIsValid(relid) || relid == catalog_get_cache_proxy_id(catalog, CACHE_TYPE_CHUNK)) + if (relid == catalog_get_cache_proxy_id(catalog, CACHE_TYPE_CHUNK)) chunk_cache_invalidate_callback(); }