mirror of
https://github.com/postgres/postgres.git
synced 2026-04-11 12:06:55 -04:00
a backend has done exit(0) or exit(1) without having disengaged itself from shared memory. We are at risk for this whenever third-party code is loaded into a backend, since such code might not know it's supposed to go through proc_exit() instead. Also, it is reported that under Windows there are ways to externally kill a process that cause the status code returned to the postmaster to be indistinguishable from a voluntary exit (thank you, Microsoft). If this does happen then the system is probably hosed --- for instance, the dead session might still be holding locks. So the best recovery method is to treat this like a backend crash. The dead man switch is armed for a particular child process when it acquires a regular PGPROC, and disarmed when the PGPROC is released; these should be the first and last touches of shared memory resources in a backend, or close enough anyway. This choice means there is no coverage for auxiliary processes, but I doubt we need that, since they shouldn't be executing any user-provided code anyway. This patch also improves the management of the EXEC_BACKEND ShmemBackendArray array a bit, by reducing search costs. Although this problem is of long standing, the lack of field complaints seems to mean it's not critical enough to risk back-patching; at least not till we get some more testing of this mechanism.
51 lines
1.4 KiB
C
51 lines
1.4 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* postmaster.h
|
|
* Exports from postmaster/postmaster.c.
|
|
*
|
|
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.20 2009/05/05 19:59:00 tgl Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef _POSTMASTER_H
|
|
#define _POSTMASTER_H
|
|
|
|
/* GUC options */
|
|
extern bool EnableSSL;
|
|
extern bool SilentMode;
|
|
extern int ReservedBackends;
|
|
extern int PostPortNumber;
|
|
extern int Unix_socket_permissions;
|
|
extern char *Unix_socket_group;
|
|
extern char *UnixSocketDir;
|
|
extern char *ListenAddresses;
|
|
extern bool ClientAuthInProgress;
|
|
extern int PreAuthDelay;
|
|
extern int AuthenticationTimeout;
|
|
extern bool Log_connections;
|
|
extern bool log_hostname;
|
|
extern char *bonjour_name;
|
|
|
|
#ifdef WIN32
|
|
extern HANDLE PostmasterHandle;
|
|
#endif
|
|
|
|
extern const char *progname;
|
|
|
|
extern int PostmasterMain(int argc, char *argv[]);
|
|
extern void ClosePostmasterPorts(bool am_syslogger);
|
|
|
|
extern int MaxLivePostmasterChildren(void);
|
|
|
|
#ifdef EXEC_BACKEND
|
|
extern pid_t postmaster_forkexec(int argc, char *argv[]);
|
|
extern int SubPostmasterMain(int argc, char *argv[]);
|
|
|
|
extern Size ShmemBackendArraySize(void);
|
|
extern void ShmemBackendArrayAllocation(void);
|
|
#endif
|
|
|
|
#endif /* _POSTMASTER_H */
|