summaryrefslogtreecommitdiff
path: root/src/backend/storage
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-09-28 20:46:37 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-09-28 20:46:37 +0000
commit3a246cc28572db1b96467f15fd4df2be1e32925d (patch)
treecbd62990e88b9cb8676cd198119aebb38ac3c9ab /src/backend/storage
parentd9b68c8061ac925f341537ab03239f239bb51f29 (diff)
Arrange to preallocate all required space for the buffer and FSM hash
tables in shared memory. This ensures that overflow of the lock table creates no long-lasting problems. Per discussion with Merlin Moncure.
Diffstat (limited to 'src/backend/storage')
-rw-r--r--src/backend/storage/freespace/freespace.c6
-rw-r--r--src/backend/storage/ipc/shmem.c13
-rw-r--r--src/backend/storage/lmgr/lock.c4
3 files changed, 16 insertions, 7 deletions
diff --git a/src/backend/storage/freespace/freespace.c b/src/backend/storage/freespace/freespace.c
index 9def3df7483..7a7d204bf5f 100644
--- a/src/backend/storage/freespace/freespace.c
+++ b/src/backend/storage/freespace/freespace.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.34 2004/08/29 05:06:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.35 2004/09/28 20:46:27 tgl Exp $
*
*
* NOTES:
@@ -283,8 +283,8 @@ InitFreeSpaceMap(void)
info.hash = tag_hash;
FreeSpaceMapRelHash = ShmemInitHash("Free Space Map Hash",
- MaxFSMRelations / 10,
- MaxFSMRelations,
+ MaxFSMRelations + 1,
+ MaxFSMRelations + 1,
&info,
(HASH_ELEM | HASH_FUNCTION));
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index d9cd8850395..29ef5413c89 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.80 2004/08/29 05:06:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.81 2004/09/28 20:46:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -262,8 +262,17 @@ InitShmemIndex(void)
* shared memory hash table.
*
* We assume caller is doing some kind of synchronization
- * so that two people dont try to create/initialize the
+ * so that two people don't try to create/initialize the
* table at once.
+ *
+ * max_size is the estimated maximum number of hashtable entries. This is
+ * not a hard limit, but the access efficiency will degrade if it is
+ * exceeded substantially (since it's used to compute directory size and
+ * the hash table buckets will get overfull).
+ *
+ * init_size is the number of hashtable entries to preallocate. For a table
+ * whose maximum size is certain, this should be equal to max_size; that
+ * ensures that no run-time out-of-shared-memory failures can occur.
*/
HTAB *
ShmemInitHash(const char *name, /* table string name for shmem index */
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index f90a3fd0e84..9699469e6d3 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.140 2004/09/12 18:30:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.141 2004/09/28 20:46:32 tgl Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@@ -241,7 +241,7 @@ LockMethodTableInit(const char *tabName,
/* Compute init/max size to request for lock hashtables */
max_table_size = NLOCKENTS(maxBackends);
- init_table_size = max_table_size / 10;
+ init_table_size = max_table_size / 2;
/* Allocate a string for the shmem index table lookups. */
/* This is just temp space in this routine, so palloc is OK. */