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

Error message editing in backend/storage.

This commit is contained in:
Tom Lane
2003-07-24 22:04:15 +00:00
parent 658fca8d3a
commit cfa191f3b8
25 changed files with 425 additions and 320 deletions

View File

@@ -1,4 +1,4 @@
$Header: /cvsroot/pgsql/src/backend/storage/ipc/README,v 1.2 2002/09/20 03:53:55 momjian Exp $
$Header: /cvsroot/pgsql/src/backend/storage/ipc/README,v 1.3 2003/07/24 22:04:09 tgl Exp $
Mon Jul 18 11:09:22 PDT 1988 W.KLAS
Cache invalidation synchronization routines:
@@ -9,23 +9,9 @@ backend can register a message which then has to be read by
all backends. A message read by all backends is removed from the
queue automatically. If a message has been lost because the buffer
was full, all backends that haven't read this message will be
noticed that they have to reset their cache state. This is done
told that they have to reset their cache state. This is done
at the time when they try to read the message queue.
The message queue is implemented as a shared buffer segment. Actually,
the queue is a circle to allow fast inserting, reading (invalidate data) and
maintaining the buffer.
Access to this shared message buffer is synchronized by the lock manager.
The lock manager treats the buffer as a regular relation and sets
relation level locks (with mode = LockWait) to block backends while
another backend is writing or reading the buffer. The identifiers used
for this special 'relation' are database id = 0 and relation id = 0.
The current implementation prints regular (e)log information
when a message has been removed from the buffer because the buffer
is full, and a backend has to reset its cache state. The elog level
is NOTICE. This can be used to improve the behavior of backends
when invalidating or resetting their cache state.

View File

@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.82 2003/05/27 17:49:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.83 2003/07/24 22:04:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,8 +28,8 @@
/*
* This flag is set during proc_exit() to change elog()'s behavior,
* so that an elog() from an on_proc_exit routine cannot get us out
* This flag is set during proc_exit() to change ereport()'s behavior,
* so that an ereport() from an on_proc_exit routine cannot get us out
* of the exit procedure. We do NOT want to go back to the idle loop...
*/
bool proc_exit_inprogress = false;
@@ -74,7 +74,7 @@ void
proc_exit(int code)
{
/*
* Once we set this flag, we are committed to exit. Any elog() will
* Once we set this flag, we are committed to exit. Any ereport() will
* NOT send control back to the main loop, but right back here.
*/
proc_exit_inprogress = true;
@@ -101,8 +101,8 @@ proc_exit(int code)
* call all the callbacks registered before calling exit().
*
* Note that since we decrement on_proc_exit_index each time, if a
* callback calls elog(ERROR) or elog(FATAL) then it won't be invoked
* again when control comes back here (nor will the
* callback calls ereport(ERROR) or ereport(FATAL) then it won't be
* invoked again when control comes back here (nor will the
* previously-completed callbacks). So, an infinite loop should not
* be possible.
*/
@@ -149,7 +149,9 @@ void
on_proc_exit(void (*function) (), Datum arg)
{
if (on_proc_exit_index >= MAX_ON_EXITS)
elog(FATAL, "Out of on_proc_exit slots");
ereport(FATAL,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg_internal("out of on_proc_exit slots")));
on_proc_exit_list[on_proc_exit_index].function = function;
on_proc_exit_list[on_proc_exit_index].arg = arg;
@@ -168,7 +170,9 @@ void
on_shmem_exit(void (*function) (), Datum arg)
{
if (on_shmem_exit_index >= MAX_ON_EXITS)
elog(FATAL, "Out of on_shmem_exit slots");
ereport(FATAL,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg_internal("out of on_shmem_exit slots")));
on_shmem_exit_list[on_shmem_exit_index].function = function;
on_shmem_exit_list[on_shmem_exit_index].arg = arg;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.53 2003/05/27 17:49:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.54 2003/07/24 22:04:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -112,7 +112,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
*/
InitLocks();
if (InitLockTable(maxBackends) == INVALID_TABLEID)
elog(FATAL, "Couldn't create the lock table");
elog(FATAL, "could not create the lock table");
/*
* Set up process table

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.68 2003/05/06 23:34:55 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.69 2003/07/24 22:04:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -158,7 +158,9 @@ ShmemAlloc(Size size)
SpinLockRelease(ShmemLock);
if (!newSpace)
elog(WARNING, "ShmemAlloc: out of memory");
ereport(WARNING,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return newSpace;
}
@@ -204,7 +206,7 @@ InitShmemIndex(void)
SHMEM_INDEX_SIZE, SHMEM_INDEX_SIZE,
&info, hash_flags);
if (!ShmemIndex)
elog(FATAL, "InitShmemIndex: couldn't initialize Shmem Index");
elog(FATAL, "could not initialize Shmem Index");
/*
* Now, create an entry in the hashtable for the index itself.
@@ -215,7 +217,9 @@ InitShmemIndex(void)
result = (ShmemIndexEnt *)
hash_search(ShmemIndex, (void *) &item, HASH_ENTER, &found);
if (!result)
elog(FATAL, "InitShmemIndex: Shmem Index out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
Assert(ShmemBootstrap && !found);
@@ -333,7 +337,9 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
if (!result)
{
LWLockRelease(ShmemIndexLock);
elog(ERROR, "ShmemInitStruct: Shmem Index out of memory");
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
return NULL;
}
@@ -348,7 +354,7 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
{
LWLockRelease(ShmemIndexLock);
elog(WARNING, "ShmemInitStruct: ShmemIndex entry size is wrong");
elog(WARNING, "ShmemIndex entry size is wrong");
/* let caller print its message too */
return NULL;
}
@@ -365,7 +371,9 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
hash_search(ShmemIndex, (void *) &item, HASH_REMOVE, NULL);
LWLockRelease(ShmemIndexLock);
elog(WARNING, "ShmemInitStruct: cannot allocate '%s'", name);
ereport(WARNING,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("could not allocate \"%s\"", name)));
*foundPtr = FALSE;
return NULL;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.56 2003/06/12 01:42:19 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.57 2003/07/24 22:04:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,9 +47,11 @@ InitBackendSharedInvalidationState(void)
flag = SIBackendInit(shmInvalBuffer);
LWLockRelease(SInvalLock);
if (flag < 0) /* unexpected problem */
elog(FATAL, "Backend cache invalidation initialization failed");
elog(FATAL, "shared cache invalidation initialization failed");
if (flag == 0) /* expected problem: MaxBackends exceeded */
elog(FATAL, "Sorry, too many clients already");
ereport(FATAL,
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
errmsg("sorry, too many clients already")));
}
/*
@@ -65,7 +67,7 @@ SendSharedInvalidMessage(SharedInvalidationMessage *msg)
insertOK = SIInsertDataEntry(shmInvalBuffer, msg);
LWLockRelease(SInvalLock);
if (!insertOK)
elog(DEBUG4, "SendSharedInvalidMessage: SI buffer overflow");
elog(DEBUG4, "SI buffer overflow");
}
/*
@@ -108,7 +110,7 @@ ReceiveSharedInvalidMessages(
if (getResult < 0)
{
/* got a reset message */
elog(DEBUG4, "ReceiveSharedInvalidMessages: cache state reset");
elog(DEBUG4, "cache state reset");
resetFunction();
}
else
@@ -336,7 +338,9 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
snapshot->xip = (TransactionId *)
malloc(MaxBackends * sizeof(TransactionId));
if (snapshot->xip == NULL)
elog(ERROR, "Memory exhausted in GetSnapshotData");
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
globalxmin = xmin = GetCurrentTransactionId();

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.50 2003/05/27 17:49:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.51 2003/07/24 22:04:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -121,7 +121,7 @@ SIBackendInit(SISeg *segP)
MyBackendId = (stateP - &segP->procState[0]) + 1;
#ifdef INVALIDDEBUG
elog(DEBUG2, "SIBackendInit: backend id %d", MyBackendId);
elog(DEBUG2, "my backend id is %d", MyBackendId);
#endif /* INVALIDDEBUG */
/* Reduce free slot count */
@@ -226,7 +226,7 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data)
if (numMsgs == (MAXNUMMESSAGES * 70 / 100) &&
IsUnderPostmaster)
{
elog(DEBUG4, "SIInsertDataEntry: table is 70%% full, signaling postmaster");
elog(DEBUG4, "SI table is 70%% full, signaling postmaster");
SendPostmasterSignal(PMSIGNAL_WAKEN_CHILDREN);
}