aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-09-02 02:57:50 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-09-02 02:57:50 +0000
commit68c323483c36b351883899c35a68c7bf496c0d4b (patch)
treedc79afde89a3ff7c867de1117dc7860d7e0224b0 /src/backend/utils/cache/relcache.c
parent4478d299e187500ad64fc990fa09c0c3728ffd63 (diff)
downloadpostgresql-68c323483c36b351883899c35a68c7bf496c0d4b.tar.gz
postgresql-68c323483c36b351883899c35a68c7bf496c0d4b.zip
Repair a bunch of problems in md.c. This builds on Hiroshi's
insight that RelationFlushRelation ought to invoke smgrclose, and that the way to make that work is to ensure that mdclose doesn't fail if the relation is already closed (or unlinked, if we are looking at a DROP TABLE). While I was testing that, I was able to identify several problems that we had with multiple-segment relations. The system is now able to do initdb and pass the regression tests with a very small segment size (I had it set to 64Kb per segment for testing). I don't believe that ever worked before. File descriptor leaks seem to be gone too. I have partially addressed the concerns we had about mdtruncate(), too. On a Win32 or NFS filesystem it is not possible to unlink a file that another backend is holding open, so what md.c now does is to truncate unwanted files to zero length before trying to unlink them. The other backends will be forced to close their open files by relation cache invalidation --- but I think it would take considerable work to make that happen before vacuum truncates the relation rather than after. Leaving zero-length files lying around seems a usable compromise.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index b6802d71f73..cae602d9e8e 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.67 1999/07/17 20:18:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.68 1999/09/02 02:57:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1256,9 +1256,13 @@ RelationFlushRelation(Relation *relationPtr,
if (!onlyFlushReferenceCountZero ||
RelationHasReferenceCountZero(relation))
{
-
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
+ /* make sure smgr and lower levels close the relation's files,
+ * if they weren't closed already
+ */
+ smgrclose(DEFAULT_SMGR, relation);
+
RelationCacheDelete(relation);
FreeTupleDesc(relation->rd_att);
@@ -1515,17 +1519,6 @@ RelationPurgeLocalRelation(bool xactCommitted)
else
smgrunlink(DEFAULT_SMGR, reln);
}
- else if (!IsBootstrapProcessingMode() && !(reln->rd_isnoname))
-
- /*
- * RelationFlushRelation () below will flush relation
- * information from the cache. We must call smgrclose to flush
- * relation information from SMGR & FMGR, too. We assume that
- * for temp relations smgrunlink is already called by
- * heap_destroyr and we skip smgrclose for them. -
- * vadim 05/22/97
- */
- smgrclose(DEFAULT_SMGR, reln);
reln->rd_myxactonly = FALSE;