aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-09-06 19:33:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-09-06 19:33:16 +0000
commitcc8b67a5c32a0cfc10be243e56d5bb10fa40f92d (patch)
tree677747ca7fad11407ef537a813d2d7f069a6932b /src
parentc5092847e76571131d09e81e93b1b8cad506dd40 (diff)
downloadpostgresql-cc8b67a5c32a0cfc10be243e56d5bb10fa40f92d.tar.gz
postgresql-cc8b67a5c32a0cfc10be243e56d5bb10fa40f92d.zip
Fix relcache.c so that local relations (those created during
current transaction) are not flushed by shared-cache-inval reset message. SI reset actually works now, for probably the first time in a long time. I was able to run initdb and regression tests with a 16-element SI message array, with a lot of NOTICE: cache state reset messages but no crashes.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/cache/relcache.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 6f5bbb7f959..db685e751eb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.71 1999/09/06 18:13:02 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.72 1999/09/06 19:33:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1264,9 +1264,12 @@ RelationFlushRelation(Relation *relationPtr,
*/
smgrclose(DEFAULT_SMGR, relation);
- if (relation->rd_isnailed)
+ if (relation->rd_isnailed || relation->rd_myxactonly)
{
- /* this is a nailed special relation for bootstrapping */
+ /* Do not flush relation cache entry if it is a nailed-in system
+ * relation or it is marked transaction-local.
+ * (To delete a local relation, caller must clear rd_myxactonly!)
+ */
return;
}
@@ -1364,6 +1367,8 @@ RelationForgetRelation(Oid rid)
MemoryContextSwitchTo(oldcxt);
}
+ relation->rd_myxactonly = false; /* so it can be flushed */
+
RelationFlushRelation(&relation, false);
}
}
@@ -1454,6 +1459,9 @@ RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId)
* Will blow away either all the cached relation descriptors or
* those that have a zero reference count.
*
+ * This is currently used only to recover from SI message buffer overflow,
+ * so onlyFlushReferenceCountZero is always false. We do not blow away
+ * transaction-local relations, since they cannot be targets of SI updates.
*/
void
RelationCacheInvalidate(bool onlyFlushReferenceCountZero)
@@ -1461,14 +1469,17 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero)
HashTableWalk(RelationNameCache, (HashtFunc) RelationFlushRelation,
onlyFlushReferenceCountZero);
- /*
- * nailed-in reldescs will still be in the cache... 6 hardwired heaps
- * + 3 hardwired indices == 9 total.
- */
if (!onlyFlushReferenceCountZero)
{
- Assert(RelationNameCache->hctl->nkeys == 9);
- Assert(RelationIdCache->hctl->nkeys == 9);
+ /*
+ * Debugging check: what's left should be transaction-local relations
+ * plus nailed-in reldescs. There should be 6 hardwired heaps
+ * + 3 hardwired indices == 9 total.
+ */
+ int numRels = length(newlyCreatedRelns) + 9;
+
+ Assert(RelationNameCache->hctl->nkeys == numRels);
+ Assert(RelationIdCache->hctl->nkeys == numRels);
}
}
@@ -1580,7 +1591,7 @@ RelationPurgeLocalRelation(bool xactCommitted)
smgrunlink(DEFAULT_SMGR, reln);
}
- reln->rd_myxactonly = FALSE;
+ reln->rd_myxactonly = false; /* so it can be flushed */
if (!IsBootstrapProcessingMode())
RelationFlushRelation(&reln, false);