MCPcopy Create free account
hub / github.com/apache/cloudberry / CatCacheInvalidate

Function CatCacheInvalidate

src/backend/utils/cache/catcache.c:552–605  ·  view source on GitHub ↗

* CatCacheInvalidate * * Invalidate entries in the specified cache, given a hash value. * * We delete cache entries that match the hash value, whether positive * or negative. We don't care whether the invalidation is the result * of a tuple insertion or a deletion. * * We used to try to match positive cache entries by TID, but that is * unsafe after a VACUUM FULL on a system catalog: an

Source from the content-addressed store, hash-verified

550 * This routine is only quasi-public: it should only be used by inval.c.
551 */
552void
553CatCacheInvalidate(CatCache *cache, uint32 hashValue)
554{
555 Index hashIndex;
556 dlist_mutable_iter iter;
557
558 CACHE_elog(DEBUG2, "CatCacheInvalidate: called");
559
560 /*
561 * We don't bother to check whether the cache has finished initialization
562 * yet; if not, there will be no entries in it so no problem.
563 */
564
565 /*
566 * Invalidate *all* CatCLists in this cache; it's too hard to tell which
567 * searches might still be correct, so just zap 'em all.
568 */
569 dlist_foreach_modify(iter, &cache->cc_lists)
570 {
571 CatCList *cl = dlist_container(CatCList, cache_elem, iter.cur);
572
573 if (cl->refcount > 0)
574 cl->dead = true;
575 else
576 CatCacheRemoveCList(cache, cl);
577 }
578
579 /*
580 * inspect the proper hash bucket for tuple matches
581 */
582 hashIndex = HASH_INDEX(hashValue, cache->cc_nbuckets);
583 dlist_foreach_modify(iter, &cache->cc_bucket[hashIndex])
584 {
585 CatCTup *ct = dlist_container(CatCTup, cache_elem, iter.cur);
586
587 if (hashValue == ct->hash_value)
588 {
589 if (ct->refcount > 0 ||
590 (ct->c_list && ct->c_list->refcount > 0))
591 {
592 ct->dead = true;
593 /* list, if any, was marked dead above */
594 Assert(ct->c_list == NULL || ct->c_list->dead);
595 }
596 else
597 CatCacheRemoveCTup(cache, ct);
598 CACHE_elog(DEBUG2, "CatCacheInvalidate: invalidated");
599#ifdef CATCACHE_STATS
600 cache->cc_invals++;
601#endif
602 /* could be multiple matches, so keep looking! */
603 }
604 }
605}
606
607/* ----------------------------------------------------------------
608 * public functions

Callers 1

SysCacheInvalidateFunction · 0.85

Calls 2

CatCacheRemoveCListFunction · 0.85
CatCacheRemoveCTupFunction · 0.85

Tested by

no test coverage detected