1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Tweak startup sequence so that running out of PROC array slots is

detected sooner in backend startup, and is treated as an expected error
(it gives 'Sorry, too many clients already' now).  This allows us not
to have to enforce the MaxBackends limit exactly in the postmaster.
Also, remove ProcRemove() and fold its functionality into ProcKill().
There's no good reason for a backend not to be responsible for removing
its PROC entry, and there are lots of good reasons for the postmaster
not to be touching shared-memory data structures.
This commit is contained in:
Tom Lane
2001-06-16 22:58:17 +00:00
parent 668db147d5
commit 2917f0a5dd
6 changed files with 85 additions and 92 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.32 2001/06/01 20:07:16 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.33 2001/06/16 22:58:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,13 +43,15 @@ CreateSharedInvalidationState(int maxBackends)
void
InitBackendSharedInvalidationState(void)
{
int flag;
SpinAcquire(SInvalLock);
if (!SIBackendInit(shmInvalBuffer))
{
SpinRelease(SInvalLock);
elog(FATAL, "Backend cache invalidation initialization failed");
}
flag = SIBackendInit(shmInvalBuffer);
SpinRelease(SInvalLock);
if (flag < 0) /* unexpected problem */
elog(FATAL, "Backend cache invalidation initialization failed");
if (flag == 0) /* expected problem: MaxBackends exceeded */
elog(FATAL, "Sorry, too many clients already");
}
/*

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.38 2001/03/22 03:59:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.39 2001/06/16 22:58:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -79,6 +79,11 @@ SIBufferInit(int maxBackends)
* SIBackendInit
* Initialize a new backend to operate on the sinval buffer
*
* Returns:
* >0 A-OK
* 0 Failed to find a free procState slot (ie, MaxBackends exceeded)
* <0 Some other failure (not currently used)
*
* NB: this routine, and all following ones, must be executed with the
* SInvalLock spinlock held, since there may be multiple backends trying
* to access the buffer.
@@ -109,12 +114,7 @@ SIBackendInit(SISeg *segP)
}
else
{
/*
* elog() with spinlock held is probably not too cool, but
* this condition should never happen anyway.
*/
elog(NOTICE, "SIBackendInit: no free procState slot available");
/* out of procState slots */
MyBackendId = InvalidBackendId;
return 0;
}