Note: Contributed by Massimo Dal Zotto
Massimo Dal Zotto��ˤ���ơ�
Postgres uses the following signals for communication between the postmaster and backends:
Postgres �Ǥϡ��ʲ��Υ����ʥ����Ѥ� �ơ�postmaster �ȥХå�����ɤδ֤��̿���Ԥʤ��ޤ���
Table 26-1. Postgres Signals
| �����ʥ� | postmaster ��ư�� | �����Ф�ư�� |
|---|---|---|
| SIGHUP | kill(*,sighup) ��¹Ԥ��ޤ��� | read_pg_options() ��¹Ԥ��ޤ��� |
| SIGINT | ��λ���ޤ��� | �䤤��碌����ߤ�ޤ��� |
| SIGQUIT | kill(*,sigterm) ��¹Ԥ��ޤ��� | handle_warn() ��¹Ԥ��ޤ��� |
| SIGTERM | kill(*,sigterm)��kill(*,9) ��¹Ԥ������θ彪λ���ޤ��� | die() ��¹Ԥ��ޤ��� |
| SIGPIPE | ̵�뤷�ޤ��� | die() ��¹Ԥ��ޤ��� ������: 6.5.3 �� postgres.c �Ǥϡ�SIG_IGN���Ĥޤꡢ̵�뤷�Ƥ��ޤ����� |
| SIGUSR1 | kill(*,sigusr1) ��¹Ԥ������θ彪λ���ޤ��� | quickdie() ��¹Ԥ��ޤ��� |
| SIGUSR2 | kill(*,sigusr2) ��¹Ԥ��ޤ��� | ��Ʊ�������Τ��ޤ���(SI ����å���νФ���Ԥʤ��ޤ���) |
| SIGCHLD | reaper()��¹Ԥ��ޤ��� | ̵�뤷�ޤ����ʻ�Τ���ޤ������ɤˤϻĤäƤ��ޤ����� ������: 6.5.3 �� postgres.c �Ǥ�SIG_IGN���Ĥޤ�̵�뤷�Ƥ��ޤ����� |
| SIGTTIN | ̵�뤷�ޤ��� | |
| SIGTTOU | ̵�뤷�ޤ��� | |
| SIGCONT | dumpstatus ��¹Ԥ��ޤ��� ������: 6.5.3 �� postmaster.c �Ǥ� SIGWINCH �� dumpstatus �ϥ�ɥ��� �����ƤƤ��ޤ��� SIGCONT �� SIG_DFL �ϥ�ɥ�ΤޤޤǤ������㤨�С�Solaris2.6 �Ǥ�̵�뤵 ��뤳�Ȥˤʤ�ޤ��� | |
| SIGFPE | FloatExceptionHandler() ��¹Ԥ��ޤ��� |
Note: "kill(*,signal)" means sending a signal to all backends.
"kill(*,signal)" �ϡ����ƤΥХå�����ɤ˰��� signal ���� �뤳�Ȥ��̣���ޤ���
The main changes to the old signal handling are the use of SIGQUIT instead of SIGHUP to handle warns, SIGHUP to re-read the pg_options file and the redirection to all active backends of SIGHUP, SIGTERM, SIGUSR1 and SIGUSR2 sent to the postmaster. In this way these signals sent to the postmaster can be sent automatically to all the backends without need to know their pids. To shut down postgres one needs only to send a SIGTERM to postmaster and it will stop automatically all the backends.
�����ʥ�μ�갷���˴ؤ�����ǤȤ��礭�ʰ㤤�ϡ��ٹ���갷������ �� SIGHUP �ǤϤʤ� SIGQUIT ����Ѥ���褦�ˤ������ȡ�pg_options �� ���������ɤ߹��ߤ��뤿��� SIGHUP ����Ѥ���褦�ˤ������ȡ����� �ơ�postmaster ������줿 SIGHUP��SIGTERM��SIGUSR1��SIGUSR2 ������ ������Ƥ�ͭ���ʥХå�����ɤ˺�������褦�ˤ������ȤǤ���������ˡ �ˤ�äơ�postmaster ������줿�����ʥ�ϡ��ץ������ֹ��Ĵ�����뤳 �Ȥʤ������Хå�����ɤ˼�ưŪ��������褦�ˤʤ�ޤ�����postgres ����ߤ��뤿��ˤ��뤳�Ȥϡ�postmaster �� SIGTERM ����������Ǥ����� ��ˤ�����ƤΥХå�����ɤϼ�ưŪ����ߤ��ޤ���
The SIGUSR2 signal is also used to prevent SI cache table overflow which happens when some backend doesn't process SI cache for a long period. When a backend detects the SI table full at 70% it simply sends a signal to the postmaster which will wake up all idle backends and make them flush the cache.
SIGUSR2 �����ʥ�ϡ��Хå�����ɤ�Ĺ���� SI ����å����������ʤ��� ��ȯ�������ǽ�������롢SI ����å���ơ��֥�Υ����С��ե������ɤ��� ��ˤ�Ȥ��ޤ�������Хå�����ɤ� SI �ơ��֥�λ��Ѿ����� 70% ��ã �������ȤФ���ȡ��Хå�����ɤ� postmaster �˥����ʥ������ޤ��� �����ʥ�������ä� postmaster �ϡ��Ԥ����֤ˤʤäƤ������ƤΥХå��� ��ɤ��������������å����Ф��ޤ���
The typical use of signals by programmers could be the following:
# stop postgres kill -TERM $postmaster_pid
# kill all the backends kill -QUIT $postmaster_pid
# kill only the postmaster kill -INT $postmaster_pid
# change pg_options cat new_pg_options > $DATA_DIR/pg_options kill -HUP $postmaster_pid
# change pg_options only for a backend cat new_pg_options > $DATA_DIR/pg_options kill -HUP $backend_pid cat old_pg_options > $DATA_DIR/pg_options
�ʲ��Τ�Τϡ��褯�ץ�����ޤ��Ԥʤ������ʥ�λ�����ˡ�Ǥ���
# postgres ����ߤ��롣 kill -TERM $postmaster_pid
# ���ƤΥХå�����ɤ���ߤ��롣 kill -QUIT $postmaster_pid
# postmaster �Τߤ���ߤ��롣 kill -INT $postmaster_pid
# pg_options ���ѹ����롣 cat new_pg_options > $DATA_DIR/pg_options kill -HUP $postmaster_pid
# �Хå�������Ѥ� pg_options �Τߤ��ѹ����롣 cat new_pg_options > $DATA_DIR/pg_options kill -HUP $backend_pid cat old_pg_options > $DATA_DIR/pg_options