mirror of
https://github.com/postgres/postgres.git
synced 2025-08-06 18:42:54 +03:00
From: Massimo Dal Zotto <dz@cs.unitn.it>
> sinval.patch > > fixes a problem in SI cache which causes table overflow if some > backend is idle for a long time while other backends keep adding > entries. > It uses the new signal handling implemented in tprintf.patch. > I have also increacasesed the max number of backends from 32 to 64 > and the table size from 1000 to 5000. > I don't know if anybody is working on SI, but until another > solution is found this patch fixes the problem. I have received > messages from other people reporting the same problem which I > fixed many months ago.
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.10 1998/06/15 19:29:15 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.11 1998/08/25 21:31:17 scrappy Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -157,8 +157,7 @@ RegisterSharedInvalid(int cacheId, /* XXX */
|
|||||||
/* should be called by a backend */
|
/* should be called by a backend */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void
|
void
|
||||||
InvalidateSharedInvalid(void (*invalFunction) (),
|
InvalidateSharedInvalid(void (*invalFunction) (), void (*resetFunction) ())
|
||||||
void (*resetFunction) ())
|
|
||||||
{
|
{
|
||||||
SpinAcquire(SInvalLock);
|
SpinAcquire(SInvalLock);
|
||||||
SIReadEntryData(shmInvalBuffer, MyBackendId,
|
SIReadEntryData(shmInvalBuffer, MyBackendId,
|
||||||
|
@@ -7,11 +7,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.12 1998/07/13 16:34:49 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.13 1998/08/25 21:31:18 scrappy Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@
|
|||||||
#include "storage/sinvaladt.h"
|
#include "storage/sinvaladt.h"
|
||||||
#include "storage/lmgr.h"
|
#include "storage/lmgr.h"
|
||||||
#include "utils/palloc.h"
|
#include "utils/palloc.h"
|
||||||
|
#include "utils/trace.h"
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* global variable notes
|
* global variable notes
|
||||||
@@ -357,6 +360,19 @@ SIGetProcStateLimit(SISeg *segP, int i)
|
|||||||
static bool
|
static bool
|
||||||
SIIncNumEntries(SISeg *segP, int num)
|
SIIncNumEntries(SISeg *segP, int num)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Try to prevent table overflow. When the table is 70% full send
|
||||||
|
* a SIGUSR2 to the postmaster which will send it back to all the
|
||||||
|
* backends. This will be handled by Async_NotifyHandler() with a
|
||||||
|
* StartTransactionCommand() which will flush unread SI entries for
|
||||||
|
* each backend. dz - 27 Jan 1998
|
||||||
|
*/
|
||||||
|
if (segP->numEntries == (MAXNUMMESSAGES * 70 / 100)) {
|
||||||
|
TPRINTF(TRACE_VERBOSE,
|
||||||
|
"SIIncNumEntries: table is 70%% full, signaling postmaster");
|
||||||
|
kill(getppid(), SIGUSR2);
|
||||||
|
}
|
||||||
|
|
||||||
if ((segP->numEntries + num) <= MAXNUMMESSAGES)
|
if ((segP->numEntries + num) <= MAXNUMMESSAGES)
|
||||||
{
|
{
|
||||||
segP->numEntries = segP->numEntries + num;
|
segP->numEntries = segP->numEntries + num;
|
||||||
@@ -655,7 +671,7 @@ SIReadEntryData(SISeg *segP,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* backend must not read messages, its own state has to be reset */
|
/* backend must not read messages, its own state has to be reset */
|
||||||
elog(NOTICE, "SIMarkEntryData: cache state reset");
|
elog(NOTICE, "SIReadEntryData: cache state reset");
|
||||||
resetFunction(); /* XXXX call it here, parameters? */
|
resetFunction(); /* XXXX call it here, parameters? */
|
||||||
|
|
||||||
/* new valid state--mark all messages "read" */
|
/* new valid state--mark all messages "read" */
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: sinvaladt.h,v 1.8 1998/02/26 04:43:35 momjian Exp $
|
* $Id: sinvaladt.h,v 1.9 1998/08/25 21:31:20 scrappy Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -44,8 +44,8 @@ C----------------End shared segment -------
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Parameters (configurable) *******************************************/
|
/* Parameters (configurable) *******************************************/
|
||||||
#define MaxBackendId 32 /* maximum number of backends */
|
#define MaxBackendId 64 /* maximum number of backends */
|
||||||
#define MAXNUMMESSAGES 1000 /* maximum number of messages in seg */
|
#define MAXNUMMESSAGES 4000 /* maximum number of messages in seg */
|
||||||
|
|
||||||
|
|
||||||
#define InvalidOffset 1000000000 /* a invalid offset (End of
|
#define InvalidOffset 1000000000 /* a invalid offset (End of
|
||||||
|
Reference in New Issue
Block a user