diff options
| author | Tom Lane | 1999-09-18 19:08:25 +0000 |
|---|---|---|
| committer | Tom Lane | 1999-09-18 19:08:25 +0000 |
| commit | bd272cace63effa23d68a6b344a07e326b6a41e2 (patch) | |
| tree | 3026c545c238bd38eadc7fb1fac89d636cf51673 /src/backend/utils/cache/catcache.c | |
| parent | 6c86fd5ba49bc03949ea1c788023f39da9c0b9fe (diff) | |
Mega-commit to make heap_open/heap_openr/heap_close take an
additional argument specifying the kind of lock to acquire/release (or
'NoLock' to do no lock processing). Ensure that all relations are locked
with some appropriate lock level before being examined --- this ensures
that relevant shared-inval messages have been processed and should prevent
problems caused by concurrent VACUUM. Fix several bugs having to do with
mismatched increment/decrement of relation ref count and mismatched
heap_open/close (which amounts to the same thing). A bogus ref count on
a relation doesn't matter much *unless* a SI Inval message happens to
arrive at the wrong time, which is probably why we got away with this
sloppiness for so long. Repair missing grab of AccessExclusiveLock in
DROP TABLE, ALTER/RENAME TABLE, etc, as noted by Hiroshi.
Recommend 'make clean all' after pulling this update; I modified the
Relation struct layout slightly.
Will post further discussion to pghackers list shortly.
Diffstat (limited to 'src/backend/utils/cache/catcache.c')
| -rw-r--r-- | src/backend/utils/cache/catcache.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index f6ef0fecac2..22d933bb37a 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.48 1999/07/17 20:18:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.49 1999/09/18 19:07:55 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -130,7 +130,8 @@ CatalogCacheInitializeCache(struct catcache * cache, /* ---------------- * If no relation was passed we must open it to get access to * its fields. If one of the other caches has already opened - * it we use heap_open() instead of heap_openr() + * it we use heap_open() instead of heap_openr(). + * XXX is that really worth the trouble of checking? * ---------------- */ if (!RelationIsValid(relation)) @@ -155,9 +156,9 @@ CatalogCacheInitializeCache(struct catcache * cache, * ---------------- */ if (cp) - relation = heap_open(cp->relationId); + relation = heap_open(cp->relationId, NoLock); else - relation = heap_openr(cache->cc_relname); + relation = heap_openr(cache->cc_relname, NoLock); didopen = 1; } @@ -217,7 +218,7 @@ CatalogCacheInitializeCache(struct catcache * cache, * ---------------- */ if (didopen) - heap_close(relation); + heap_close(relation, NoLock); /* ---------------- * initialize index information for the cache. this @@ -891,10 +892,10 @@ SearchSysCache(struct catcache * cache, DLMoveToFront(elt); #ifdef CACHEDEBUG - relation = heap_open(cache->relationId); + relation = heap_open(cache->relationId, NoLock); CACHE3_elog(DEBUG, "SearchSysCache(%s): found in bucket %d", RelationGetRelationName(relation), hash); - heap_close(relation); + heap_close(relation, NoLock); #endif /* CACHEDEBUG */ return ct->ct_tup; @@ -925,7 +926,7 @@ SearchSysCache(struct catcache * cache, * open the relation associated with the cache * ---------------- */ - relation = heap_open(cache->relationId); + relation = heap_open(cache->relationId, AccessShareLock); CACHE2_elog(DEBUG, "SearchSysCache(%s)", RelationGetRelationName(relation)); @@ -1082,7 +1083,7 @@ SearchSysCache(struct catcache * cache, * and return the tuple we found (or NULL) * ---------------- */ - heap_close(relation); + heap_close(relation, AccessShareLock); MemoryContextSwitchTo(oldcxt); return ntp; @@ -1146,8 +1147,6 @@ RelationInvalidateCatalogCacheTuple(Relation relation, (*function) (ccp->id, CatalogCacheComputeTupleHashIndex(ccp, relation, tuple), &tuple->t_self); - - heap_close(relation); } /* ---------------- |
