? GNUmakefile ? config.log ? config.status ? make1.log ? make2.log ? src/Makefile.global ? src/backend/postgres ? src/backend/catalog/postgres.bki ? src/backend/catalog/postgres.description ? src/backend/catalog/postgres.shdescription ? src/backend/snowball/snowball_create.sql ? src/backend/utils/probes.h ? src/backend/utils/mb/conversion_procs/conversion_create.sql ? src/bin/initdb/initdb ? src/bin/pg_config/pg_config ? src/bin/pg_controldata/pg_controldata ? src/bin/pg_ctl/pg_ctl ? src/bin/pg_dump/pg_dump ? src/bin/pg_dump/pg_dumpall ? src/bin/pg_dump/pg_restore ? src/bin/pg_resetxlog/pg_resetxlog ? src/bin/psql/psql ? src/bin/scripts/clusterdb ? src/bin/scripts/createdb ? src/bin/scripts/createlang ? src/bin/scripts/createuser ? src/bin/scripts/dropdb ? src/bin/scripts/droplang ? src/bin/scripts/dropuser ? src/bin/scripts/reindexdb ? src/bin/scripts/vacuumdb ? src/include/pg_config.h ? src/include/stamp-h ? src/interfaces/ecpg/compatlib/exports.list ? src/interfaces/ecpg/compatlib/libecpg_compat.so.3.1 ? src/interfaces/ecpg/ecpglib/exports.list ? src/interfaces/ecpg/ecpglib/libecpg.so.6.1 ? src/interfaces/ecpg/include/ecpg_config.h ? src/interfaces/ecpg/pgtypeslib/exports.list ? src/interfaces/ecpg/pgtypeslib/libpgtypes.so.3.1 ? src/interfaces/ecpg/preproc/ecpg ? src/interfaces/libpq/exports.list ? src/interfaces/libpq/libpq.so.5.2 ? src/port/pg_config_paths.h ? src/test/regress/log ? src/test/regress/pg_regress ? src/test/regress/regression.diffs ? src/test/regress/regression.out ? src/test/regress/results ? src/test/regress/testtablespace ? src/test/regress/tmp_check ? src/test/regress/expected/constraints.out ? src/test/regress/expected/copy.out ? src/test/regress/expected/create_function_1.out ? src/test/regress/expected/create_function_2.out ? src/test/regress/expected/largeobject.out ? src/test/regress/expected/largeobject_1.out ? src/test/regress/expected/misc.out ? src/test/regress/expected/tablespace.out ? src/test/regress/sql/constraints.sql ? src/test/regress/sql/copy.sql ? src/test/regress/sql/create_function_1.sql ? src/test/regress/sql/create_function_2.sql ? src/test/regress/sql/largeobject.sql ? src/test/regress/sql/misc.sql ? src/test/regress/sql/tablespace.sql ? src/timezone/zic Index: src/backend/access/transam/twophase.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/twophase.c,v retrieving revision 1.45 diff -c -r1.45 twophase.c *** src/backend/access/transam/twophase.c 11 Aug 2008 11:05:10 -0000 1.45 --- src/backend/access/transam/twophase.c 15 Sep 2008 06:50:55 -0000 *************** *** 285,290 **** --- 285,291 ---- gxact->proc.databaseId = databaseid; gxact->proc.roleId = owner; gxact->proc.inCommit = false; + gxact->proc.signalFlags = 0; gxact->proc.vacuumFlags = 0; gxact->proc.lwWaiting = false; gxact->proc.lwExclusive = false; Index: src/backend/postmaster/autovacuum.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/postmaster/autovacuum.c,v retrieving revision 1.84 diff -c -r1.84 autovacuum.c *** src/backend/postmaster/autovacuum.c 13 Aug 2008 00:07:50 -0000 1.84 --- src/backend/postmaster/autovacuum.c 15 Sep 2008 06:50:56 -0000 *************** *** 1480,1486 **** pqsignal(SIGALRM, handle_sig_alarm); pqsignal(SIGPIPE, SIG_IGN); ! pqsignal(SIGUSR1, CatchupInterruptHandler); /* We don't listen for async notifies */ pqsignal(SIGUSR2, SIG_IGN); pqsignal(SIGFPE, FloatExceptionHandler); --- 1480,1486 ---- pqsignal(SIGALRM, handle_sig_alarm); pqsignal(SIGPIPE, SIG_IGN); ! pqsignal(SIGUSR1, proc_sigusr1_handler); /* We don't listen for async notifies */ pqsignal(SIGUSR2, SIG_IGN); pqsignal(SIGFPE, FloatExceptionHandler); Index: src/backend/storage/ipc/sinval.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v retrieving revision 1.86 diff -c -r1.86 sinval.c *** src/backend/storage/ipc/sinval.c 19 Jun 2008 21:32:56 -0000 1.86 --- src/backend/storage/ipc/sinval.c 15 Sep 2008 06:50:56 -0000 *************** *** 144,150 **** /* ! * CatchupInterruptHandler * * This is the signal handler for SIGUSR1. * --- 144,150 ---- /* ! * HandleCatchupInterrupt * * This is the signal handler for SIGUSR1. * *************** *** 156,165 **** * since there's no longer any reason to do anything.) */ void ! CatchupInterruptHandler(SIGNAL_ARGS) { - int save_errno = errno; - /* * Note: this is a SIGNAL HANDLER. You must be very wary what you do * here. --- 156,163 ---- * since there's no longer any reason to do anything.) */ void ! HandleCatchupInterrupt(void) { /* * Note: this is a SIGNAL HANDLER. You must be very wary what you do * here. *************** *** 216,223 **** */ catchupInterruptOccurred = 1; } - - errno = save_errno; } /* --- 214,219 ---- Index: src/backend/storage/ipc/sinvaladt.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v retrieving revision 1.74 diff -c -r1.74 sinvaladt.c *** src/backend/storage/ipc/sinvaladt.c 18 Jul 2008 14:45:48 -0000 1.74 --- src/backend/storage/ipc/sinvaladt.c 15 Sep 2008 06:50:56 -0000 *************** *** 655,661 **** LWLockRelease(SInvalReadLock); LWLockRelease(SInvalWriteLock); elog(DEBUG4, "sending sinval catchup signal to PID %d", (int) his_pid); ! kill(his_pid, SIGUSR1); if (callerHasWriteLock) LWLockAcquire(SInvalWriteLock, LW_EXCLUSIVE); } --- 655,661 ---- LWLockRelease(SInvalReadLock); LWLockRelease(SInvalWriteLock); elog(DEBUG4, "sending sinval catchup signal to PID %d", (int) his_pid); ! SendProcSignal(his_pid, PROCSIGNAL_CATCHUP_INTERRUPT); if (callerHasWriteLock) LWLockAcquire(SInvalWriteLock, LW_EXCLUSIVE); } Index: src/backend/storage/lmgr/proc.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v retrieving revision 1.201 diff -c -r1.201 proc.c *** src/backend/storage/lmgr/proc.c 9 Jun 2008 18:23:05 -0000 1.201 --- src/backend/storage/lmgr/proc.c 15 Sep 2008 06:50:56 -0000 *************** *** 88,93 **** --- 88,95 ---- static void AuxiliaryProcKill(int code, Datum arg); static bool CheckStatementTimeout(void); + static PGPROC *AuxiliaryPidGetProc(int pid); + /* * Report shared-memory space needed by InitProcGlobal. *************** *** 291,296 **** --- 293,299 ---- MyProc->databaseId = InvalidOid; MyProc->roleId = InvalidOid; MyProc->inCommit = false; + MyProc->signalFlags = 0; MyProc->vacuumFlags = 0; if (IsAutoVacuumWorkerProcess()) MyProc->vacuumFlags |= PROC_IS_AUTOVACUUM; *************** *** 430,435 **** --- 433,439 ---- MyProc->databaseId = InvalidOid; MyProc->roleId = InvalidOid; MyProc->inCommit = false; + MyProc->signalFlags = 0; /* we don't set the "is autovacuum" flag in the launcher */ MyProc->vacuumFlags = 0; MyProc->lwWaiting = false; *************** *** 1281,1286 **** --- 1285,1377 ---- PGSemaphoreUnlock(&proc->sem); } + /* + * SendProcSignal - send a signal with a reason to a process + * (such as backend, autovacuum worker and auxiliary process) + * identified by PID. + */ + void + SendProcSignal(int pid, uint8 reason) + { + PGPROC *proc = NULL; + + /* + * If a given pid is not for a backend or an auxiliary process, + * do nothing. + */ + if ((proc = BackendPidGetProc(pid)) == NULL + && (proc = AuxiliaryPidGetProc(pid)) == NULL) + return; + + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); + + proc->signalFlags |= reason; + + LWLockRelease(ProcArrayLock); + + /* Send SIGUSR1 to a process */ + kill(pid, SIGUSR1); + } + + /* + * CheckProcSignal - check to see if a particular reason has been + * signaled, and clear the signal flag. Should be called after + * receiving SIGUSR1. + */ + bool + CheckProcSignal(uint8 reason) + { + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); + + /* Careful here --- don't clear flag if we haven't seen it set */ + if (MyProc->signalFlags & reason) + { + MyProc->signalFlags &= ~reason; + LWLockRelease(ProcArrayLock); + return true; + } + + LWLockRelease(ProcArrayLock); + + return false; + } + + /* + * AuxiliaryPidGetProc - get an auxiliary process's PGPROC given its PID + * + * Returns NULL if not found. Note that it is up to the caller to be + * sure that the question remains meaningful for long enough for the + * answer to be used ... + */ + static PGPROC * + AuxiliaryPidGetProc(int pid) + { + PGPROC *result = NULL; + int proctype; + + if (pid == 0) + return NULL; + + LWLockAcquire(ProcArrayLock, LW_SHARED); + + for (proctype = 0; proctype < NUM_AUXILIARY_PROCS; proctype++) + { + PGPROC *proc = &AuxiliaryProcs[proctype]; + + if (proc->pid == 0) + break; + + if (proc->pid == pid) + { + result = proc; + break; + } + } + + LWLockRelease(ProcArrayLock); + + return result; + } /***************************************************************************** * SIGALRM interrupt support Index: src/backend/tcop/postgres.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/tcop/postgres.c,v retrieving revision 1.556 diff -c -r1.556 postgres.c *** src/backend/tcop/postgres.c 19 Aug 2008 18:30:04 -0000 1.556 --- src/backend/tcop/postgres.c 15 Sep 2008 06:50:56 -0000 *************** *** 2434,2439 **** --- 2434,2458 ---- */ /* + * proc_sigusr1_handler - handle signal conditions. + */ + void + proc_sigusr1_handler(SIGNAL_ARGS) + { + int save_errno = errno; + + if (CheckProcSignal(PROCSIGNAL_CATCHUP_INTERRUPT)) + { + /* + * Catchup interrupt has been sent. + */ + HandleCatchupInterrupt(); + } + + errno = save_errno; + } + + /* * quickdie() occurs when signalled SIGQUIT by the postmaster. * * Some backend has bought the farm, *************** *** 3177,3183 **** * of output during who-knows-what operation... */ pqsignal(SIGPIPE, SIG_IGN); ! pqsignal(SIGUSR1, CatchupInterruptHandler); pqsignal(SIGUSR2, NotifyInterruptHandler); pqsignal(SIGFPE, FloatExceptionHandler); --- 3196,3202 ---- * of output during who-knows-what operation... */ pqsignal(SIGPIPE, SIG_IGN); ! pqsignal(SIGUSR1, proc_sigusr1_handler); pqsignal(SIGUSR2, NotifyInterruptHandler); pqsignal(SIGFPE, FloatExceptionHandler); Index: src/include/storage/proc.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/storage/proc.h,v retrieving revision 1.106 diff -c -r1.106 proc.h *** src/include/storage/proc.h 15 Apr 2008 20:28:47 -0000 1.106 --- src/include/storage/proc.h 15 Sep 2008 06:50:56 -0000 *************** *** 38,43 **** --- 38,46 ---- TransactionId xids[PGPROC_MAX_CACHED_SUBXIDS]; }; + /* Flags for PGPROC->signalFlags */ + #define PROCSIGNAL_CATCHUP_INTERRUPT 0x01 /* catchup interrupt */ + /* Flags for PGPROC->vacuumFlags */ #define PROC_IS_AUTOVACUUM 0x01 /* is it an autovac worker? */ #define PROC_IN_VACUUM 0x02 /* currently running lazy vacuum */ *************** *** 91,96 **** --- 94,100 ---- bool inCommit; /* true if within commit critical section */ + uint8 signalFlags; /* signal-related flags, see above */ uint8 vacuumFlags; /* vacuum-related flags, see above */ /* Info about LWLock the process is currently waiting for, if any. */ *************** *** 171,176 **** --- 175,183 ---- extern void ProcWaitForSignal(void); extern void ProcSendSignal(int pid); + extern void SendProcSignal(int pid, uint8 reason); + extern bool CheckProcSignal(uint8 reason); + extern bool enable_sig_alarm(int delayms, bool is_statement_timeout); extern bool disable_sig_alarm(bool is_statement_timeout); extern void handle_sig_alarm(SIGNAL_ARGS); Index: src/include/storage/sinval.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/storage/sinval.h,v retrieving revision 1.48 diff -c -r1.48 sinval.h *** src/include/storage/sinval.h 19 Jun 2008 21:32:56 -0000 1.48 --- src/include/storage/sinval.h 15 Sep 2008 06:50:56 -0000 *************** *** 90,96 **** void (*resetFunction) (void)); /* signal handler for catchup events (SIGUSR1) */ ! extern void CatchupInterruptHandler(SIGNAL_ARGS); /* * enable/disable processing of catchup events directly from signal handler. --- 90,96 ---- void (*resetFunction) (void)); /* signal handler for catchup events (SIGUSR1) */ ! extern void HandleCatchupInterrupt(void); /* * enable/disable processing of catchup events directly from signal handler. Index: src/include/tcop/tcopprot.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/tcop/tcopprot.h,v retrieving revision 1.93 diff -c -r1.93 tcopprot.h *** src/include/tcop/tcopprot.h 10 Mar 2008 12:55:13 -0000 1.93 --- src/include/tcop/tcopprot.h 15 Sep 2008 06:50:56 -0000 *************** *** 56,61 **** --- 56,62 ---- extern bool assign_max_stack_depth(int newval, bool doit, GucSource source); + extern void proc_sigusr1_handler(SIGNAL_ARGS); extern void die(SIGNAL_ARGS); extern void quickdie(SIGNAL_ARGS); extern void authdie(SIGNAL_ARGS);