Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04103e0

Browse files
committed
Modify uses of RelationFlushRelation and RelationCacheInvalidate so that
we *always* rebuild, rather than deleting, an invalidated relcache entrythat has positive refcount. Otherwise an SI cache overrun leads todangling Relation pointers all over the place!
1 parent98c6e81 commit04103e0

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

‎src/backend/utils/cache/inval.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.32 2000/01/26 05:57:17 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.33 2000/01/29 19:51:59 tgl Exp $
1212
*
1313
* Note - this code is real crufty...
1414
*
@@ -548,15 +548,16 @@ CacheIdInvalidate(Index cacheId,
548548
/* --------------------------------
549549
*ResetSystemCaches
550550
*
551-
*this blows away all tuples in the system catalog caches and
552-
*all the cached relation descriptors (and closes the files too).
551+
*This blows away all tuples in the system catalog caches and
552+
*all the cached relation descriptors (and closes their files too).
553+
*Relation descriptors that have positive refcounts are then rebuilt.
553554
* --------------------------------
554555
*/
555556
staticvoid
556557
ResetSystemCaches()
557558
{
558559
ResetSystemCache();
559-
RelationCacheInvalidate(false);
560+
RelationCacheInvalidate(true);
560561
}
561562

562563
/* --------------------------------

‎src/backend/utils/cache/relcache.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.87 2000/01/26 05:57:17 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.88 2000/01/29 19:51:59 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1406,14 +1406,26 @@ RelationIdInvalidateRelationCacheByRelationId(Oid relationId)
14061406
*/
14071407
if (PointerIsValid(relation)&& !relation->rd_myxactonly)
14081408
{
1409-
1409+
#if1
1410+
/*
1411+
* Seems safest just to NEVER flush rels with positive refcounts.
1412+
* I think the code only had that proviso as a rather lame method of
1413+
* cleaning up unused relcache entries that had dangling refcounts
1414+
* (following elog(ERROR) with an open rel). Now we rely on
1415+
* RelationCacheAbort to clean up dangling refcounts, so there's no
1416+
* good reason to ever risk flushing a rel with positive refcount.
1417+
* IMHO anyway --- tgl 1/29/00.
1418+
*/
1419+
RelationFlushRelation(&relation, true);
1420+
#else
14101421
/*
14111422
* The boolean onlyFlushReferenceCountZero in RelationFlushReln()
14121423
* should be set to true when we are incrementing the command
14131424
* counter and to false when we are starting a new xaction. This
14141425
* can be determined by checking the current xaction status.
14151426
*/
14161427
RelationFlushRelation(&relation,CurrentXactInProgress());
1428+
#endif
14171429
}
14181430
}
14191431

@@ -1436,7 +1448,7 @@ RelationFlushIndexes(Relation *r,
14361448
if (relation->rd_rel->relkind==RELKIND_INDEX&&/* XXX style */
14371449
(!OidIsValid(accessMethodId)||
14381450
relation->rd_rel->relam==accessMethodId))
1439-
RelationFlushRelation(&relation,false);
1451+
RelationFlushRelation(&relation,true);
14401452
}
14411453

14421454
#endif
@@ -1469,9 +1481,14 @@ RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId)
14691481
* Will blow away either all the cached relation descriptors or
14701482
* those that have a zero reference count.
14711483
*
1484+
* CAUTION: this is only called with onlyFlushReferenceCountZero=true
1485+
* at present, so that relation descriptors with positive refcounts
1486+
* are rebuilt rather than clobbered. It would only be safe to use a
1487+
* "false" parameter in a totally idle backend with no open relations.
1488+
*
14721489
* This is currently used only to recover from SI message buffer overflow,
1473-
* soonlyFlushReferenceCountZero is always false. We do not blow away
1474-
*transaction-local relations, since they cannot betargets of SI updates.
1490+
* sowe do not blow away transaction-local relations; they cannot be
1491+
* targets of SI updates.
14751492
*/
14761493
void
14771494
RelationCacheInvalidate(boolonlyFlushReferenceCountZero)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp