1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Modify RelationFlushRelation so that if the relcache entry

has positive refcount, it is rebuilt from pg_class data.  This ensures
that relcache entries will track changes made by other backends.  Formerly,
a shared inval report would just be ignored if it happened to arrive while
the relcache entry was in use.  Also, fix relcache to reset ref counts
to zero during transaction abort.  Finally, change LockRelation() so that
it checks for shared inval reports after obtaining the lock.  In this way,
once any kind of lock has been obtained on a rel, we can trust the relcache
entry to be up-to-date.
This commit is contained in:
Tom Lane
1999-09-04 18:42:15 +00:00
parent 8add6d71cf
commit b4a607c9e0
4 changed files with 138 additions and 56 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.33 1999/07/17 20:17:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.34 1999/09/04 18:42:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,6 +22,7 @@
#include "postgres.h"
#include "access/transam.h"
#include "catalog/catalog.h"
#include "utils/inval.h"
extern Oid MyDatabaseId;
@@ -161,7 +162,16 @@ LockRelation(Relation relation, LOCKMODE lockmode)
tag.objId.blkno = InvalidBlockNumber;
LockAcquire(LockTableId, &tag, lockmode);
return;
/*
* Check to see if the relcache entry has been invalidated
* while we were waiting to lock it. If so, rebuild it,
* or elog() trying. Increment the refcount to ensure that
* RelationFlushRelation will rebuild it and not just delete it.
*/
RelationIncrementReferenceCount(relation);
DiscardInvalid();
RelationDecrementReferenceCount(relation);
}
/*