1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Fix up flushing of composite-type typcache entries to be driven directly by

SI invalidation events, rather than indirectly through the relcache.

In the previous coding, we had to flush a composite-type typcache entry
whenever we discarded the corresponding relcache entry.  This caused problems
at least when testing with RELCACHE_FORCE_RELEASE, as shown in recent report
from Jeff Davis, and might result in real-world problems given the kind of
unexpected relcache flush that that test mechanism is intended to model.

The new coding decouples relcache and typcache management, which is a good
thing anyway from a structural perspective.  The cost is that we have to
search the typcache linearly to find entries that need to be flushed.  There
are a couple of ways we could avoid that, but at the moment it's not clear
it's worth any extra trouble, because the typcache contains very few entries
in typical operation.

Back-patch to 8.2, the same as some other recent fixes in this general area.
The patch could be carried back to 8.0 with some additional work, but given
that it's only hypothetical whether we're fixing any problem observable in
the field, it doesn't seem worth the work now.
This commit is contained in:
Tom Lane
2010-09-02 03:16:46 +00:00
parent f3c903f867
commit 9513918c6c
3 changed files with 53 additions and 43 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.312 2010/08/13 20:10:52 rhaas Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.313 2010/09/02 03:16:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -77,7 +77,6 @@
#include "utils/resowner.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
#include "utils/typcache.h"
/*
@ -1854,8 +1853,6 @@ RelationDestroyRelation(Relation relation)
static void
RelationClearRelation(Relation relation, bool rebuild)
{
Oid old_reltype = relation->rd_rel->reltype;
/*
* As per notes above, a rel to be rebuilt MUST have refcnt > 0; while of
* course it would be a bad idea to blow away one with nonzero refcnt.
@ -1925,9 +1922,6 @@ RelationClearRelation(Relation relation, bool rebuild)
*/
if (!rebuild)
{
/* Flush any rowtype cache entry */
flush_rowtype_cache(old_reltype);
/* Remove it from the hash table */
RelationCacheDelete(relation);
@ -1975,7 +1969,6 @@ RelationClearRelation(Relation relation, bool rebuild)
if (newrel == NULL)
{
/* Should only get here if relation was deleted */
flush_rowtype_cache(old_reltype);
RelationCacheDelete(relation);
RelationDestroyRelation(relation);
elog(ERROR, "relation %u deleted while still in use", save_relid);
@ -1983,8 +1976,6 @@ RelationClearRelation(Relation relation, bool rebuild)
keep_tupdesc = equalTupleDescs(relation->rd_att, newrel->rd_att);
keep_rules = equalRuleLocks(relation->rd_rules, newrel->rd_rules);
if (!keep_tupdesc)
flush_rowtype_cache(old_reltype);
/*
* Perform swapping of the relcache entry contents. Within this