mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Allow maximum number of backends to be set at configure time
(--with-maxbackends). Add a postmaster switch (-N backends) that allows the limit to be reduced at postmaster start time. (You can't increase it, sorry to say, because there are still some fixed-size arrays.) Grab the number of semaphores indicated by min(MAXBACKENDS, -N) at postmaster startup, so that this particular form of bogus configuration is exposed immediately rather than under heavy load.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.18 1999/02/13 23:18:11 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.19 1999/02/19 06:06:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -44,17 +44,19 @@ SystemPortAddressCreateIPCKey(SystemPortAddress address)
|
||||
|
||||
CreateSharedMemoryAndSemaphores
|
||||
is called exactly *ONCE* by the postmaster.
|
||||
It is *NEVER* called by the postgres backend
|
||||
It is *NEVER* called by the postgres backend,
|
||||
except in the case of a standalone backend.
|
||||
|
||||
0) destroy any existing semaphores for both buffer
|
||||
and lock managers.
|
||||
1) create the appropriate *SHARED* memory segments
|
||||
for the two resource managers.
|
||||
2) create shared semaphores as needed.
|
||||
|
||||
**************************************************/
|
||||
|
||||
void
|
||||
CreateSharedMemoryAndSemaphores(IPCKey key)
|
||||
CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
|
||||
{
|
||||
int size;
|
||||
|
||||
@@ -98,7 +100,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key)
|
||||
* do process table stuff
|
||||
* ----------------
|
||||
*/
|
||||
InitProcGlobal(key);
|
||||
InitProcGlobal(key, maxBackends);
|
||||
on_shmem_exit(ProcFreeAllSemaphores, NULL);
|
||||
|
||||
CreateSharedInvalidationState(key);
|
||||
@@ -120,7 +122,7 @@ AttachSharedMemoryAndSemaphores(IPCKey key)
|
||||
*/
|
||||
if (key == PrivateIPCKey)
|
||||
{
|
||||
CreateSharedMemoryAndSemaphores(key);
|
||||
CreateSharedMemoryAndSemaphores(key, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.16 1999/02/13 23:18:16 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.17 1999/02/19 06:06:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -119,7 +119,7 @@ SIAssignBackendId(SISeg *segInOutP, BackendTag backendTag)
|
||||
|
||||
stateP = NULL;
|
||||
|
||||
for (index = 0; index < MaxBackendId; index += 1)
|
||||
for (index = 0; index < MAXBACKENDS; index++)
|
||||
{
|
||||
if (segInOutP->procState[index].tag == InvalidBackendTag ||
|
||||
segInOutP->procState[index].tag == backendTag)
|
||||
@@ -141,7 +141,7 @@ SIAssignBackendId(SISeg *segInOutP, BackendTag backendTag)
|
||||
|
||||
/* verify that all "procState" entries checked for matching tags */
|
||||
|
||||
for (index += 1; index < MaxBackendId; index += 1)
|
||||
for (index++; index < MAXBACKENDS; index++)
|
||||
{
|
||||
if (segInOutP->procState[index].tag == backendTag)
|
||||
{
|
||||
@@ -565,7 +565,7 @@ SIDecProcLimit(SISeg *segP, int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MaxBackendId; i++)
|
||||
for (i = 0; i < MAXBACKENDS; i++)
|
||||
{
|
||||
/* decrement only, if there is a limit > 0 */
|
||||
if (segP->procState[i].limit > 0)
|
||||
@@ -622,7 +622,7 @@ SISetProcStateInvalid(SISeg *segP)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MaxBackendId; i++)
|
||||
for (i = 0; i < MAXBACKENDS; i++)
|
||||
{
|
||||
if (segP->procState[i].limit == 0)
|
||||
{
|
||||
@@ -696,7 +696,7 @@ SIDelExpiredDataEntries(SISeg *segP)
|
||||
h;
|
||||
|
||||
min = 9999999;
|
||||
for (i = 0; i < MaxBackendId; i++)
|
||||
for (i = 0; i < MAXBACKENDS; i++)
|
||||
{
|
||||
h = SIGetProcStateLimit(segP, i);
|
||||
if (h >= 0)
|
||||
@@ -740,7 +740,7 @@ SISegInit(SISeg *segP)
|
||||
SISetEndEntryChain(segP, InvalidOffset);
|
||||
SISetNumEntries(segP, 0);
|
||||
SISetMaxNumEntries(segP, MAXNUMMESSAGES);
|
||||
for (i = 0; i < MaxBackendId; i++)
|
||||
for (i = 0; i < MAXBACKENDS; i++)
|
||||
{
|
||||
segP->procState[i].limit = -1; /* no backend active !! */
|
||||
segP->procState[i].resetState = false;
|
||||
|
||||
Reference in New Issue
Block a user