diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-04 18:42:15 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-04 18:42:15 +0000 |
commit | b4a607c9e0538a3047d156404cf48de7ea878b0b (patch) | |
tree | 853b70ac122b5ee79233e9fbb64fd3bd46ecf728 /src/backend/storage/lmgr/lmgr.c | |
parent | 8add6d71cff28d087872215b02c7a0b84ba786c4 (diff) |
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.
Diffstat (limited to 'src/backend/storage/lmgr/lmgr.c')
-rw-r--r-- | src/backend/storage/lmgr/lmgr.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c index df8f991fae7..839533952b5 100644 --- a/src/backend/storage/lmgr/lmgr.c +++ b/src/backend/storage/lmgr/lmgr.c @@ -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); } /* |