signals.sgml
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:3k
源码类别:

数据库系统

开发平台:

Unix_Linux

  1. <chapter id="signals">
  2. <DocInfo>
  3. <AuthorGroup>
  4. <Author>
  5. <FirstName>Massimo</FirstName>
  6. <Surname>Dal Zotto</Surname>
  7. </Author>
  8. </AuthorGroup>
  9. <Date>Transcribed 1998-10-16</Date>
  10. </DocInfo>
  11. <title><productname>Postgres</productname> Signals</title>
  12. <Para>
  13. <Note>
  14. <Para>
  15. Contributed by <ULink url="mailto:dz@cs.unitn.it">Massimo Dal Zotto</ULink>
  16. </Para>
  17. </Note>
  18. </para>
  19. <para>
  20. <productname>Postgres</productname> uses the following signals for
  21.  communication between the postmaster and backends:
  22. </para>
  23. <para>
  24. <table tocentry="1">
  25. <title><productname>Postgres</productname> Signals</title>
  26. <titleabbrev>Signals</titleabbrev>
  27. <tgroup cols="2">
  28. <thead>
  29. <row>
  30. <entry>
  31. Signal
  32. </entry>
  33. <entry>
  34. <application>postmaster</application> Action
  35. </entry>
  36. <entry>
  37. Server Action
  38. </entry>
  39. </row>
  40. </thead>
  41. <tbody>
  42. <row>
  43. <entry>
  44. SIGHUP
  45. </entry>
  46. <entry>
  47. kill(*,sighup)
  48. </entry>
  49. <entry>
  50. read_pg_options
  51. </entry>
  52. </row>
  53. <row>
  54. <entry>
  55. SIGINT
  56. </entry>
  57. <entry>
  58. die
  59. </entry>
  60. <entry>
  61. cancel query
  62. </entry>
  63. </row>
  64. <row>
  65. <entry>
  66. SIGQUIT
  67. </entry>
  68. <entry>
  69. kill(*,sigterm)
  70. </entry>
  71. <entry>
  72. handle_warn
  73. </entry>
  74. </row>
  75. <row>
  76. <entry>
  77. SIGTERM
  78. </entry>
  79. <entry>
  80. kill(*,sigterm), kill(*,9), die
  81. </entry>
  82. <entry>
  83. die
  84. </entry>
  85. </row>
  86. <row>
  87. <entry>
  88. SIGPIPE
  89. </entry>
  90. <entry>
  91. ignored
  92. </entry>
  93. <entry>
  94. die
  95. </entry>
  96. </row>
  97. <row>
  98. <entry>
  99. SIGUSR1
  100. </entry>
  101. <entry>
  102. kill(*,sigusr1), die
  103. </entry>
  104. <entry>
  105. quickdie
  106. </entry>
  107. </row>
  108. <row>
  109. <entry>
  110. SIGUSR2
  111. </entry>
  112. <entry>
  113. kill(*,sigusr2)
  114. </entry>
  115. <entry>
  116. async notify (SI flush)
  117. </entry>
  118. </row>
  119. <row>
  120. <entry>
  121. SIGCHLD
  122. </entry>
  123. <entry>
  124. reaper
  125. </entry>
  126. <entry>
  127. ignored (alive test)
  128. </entry>
  129. </row>
  130. <row>
  131. <entry>
  132. SIGTTIN
  133. </entry>
  134. <entry>
  135. ignored
  136. </entry>
  137. <entry>
  138. </entry>
  139. </row>
  140. <row>
  141. <entry>
  142. SIGTTOU
  143. </entry>
  144. <entry>
  145. ignored
  146. </entry>
  147. <entry>
  148. </entry>
  149. </row>
  150. <row>
  151. <entry>
  152. SIGCONT
  153. </entry>
  154. <entry>
  155. dumpstatus
  156. </entry>
  157. <entry>
  158. </entry>
  159. </row>
  160. <row>
  161. <entry>
  162. SIGFPE
  163. </entry>
  164. <entry>
  165. </entry>
  166. <entry>
  167. FloatExceptionHandler
  168. </entry>
  169. </row>
  170. </tbody>
  171. </tgroup>
  172. </table>
  173. <note>
  174. <para>
  175. <quote>kill(*,signal)</quote> means sending a signal to all backends.
  176. </para>
  177. </note>
  178. </para>
  179. <para>
  180. The main changes to the old signal handling are the use of SIGQUIT instead
  181. of SIGHUP to handle warns, SIGHUP to re-read the pg_options file and the
  182. redirection to all active backends of SIGHUP, SIGTERM, SIGUSR1 and SIGUSR2
  183. sent to the postmaster.
  184. In this way these signals sent to the postmaster can be sent
  185. automatically to all the backends without need to know their pids.
  186. To shut down postgres one needs only to send a SIGTERM to postmaster
  187. and it will stop automatically all the backends.
  188. </para>
  189. <para>
  190. The SIGUSR2 signal is also used to prevent SI cache table overflow
  191. which happens when some backend doesn't process SI cache for a long period.
  192. When a backend detects the SI table full at 70% it simply sends a signal
  193. to the postmaster which will wake up all idle backends and make them flush
  194. the cache.
  195. </para>
  196. <para>
  197. The typical use of signals by programmers could be the following:
  198. <programlisting>
  199. # stop postgres
  200. kill -TERM $postmaster_pid
  201. </programlisting>
  202. <programlisting>
  203. # kill all the backends
  204. kill -QUIT $postmaster_pid
  205. </programlisting>
  206. <programlisting>
  207. # kill only the postmaster
  208. kill -INT $postmaster_pid
  209. </programlisting>
  210. <programlisting>
  211. # change pg_options
  212. cat new_pg_options > $DATA_DIR/pg_options
  213. kill -HUP $postmaster_pid
  214. </programlisting>
  215. <programlisting>
  216. # change pg_options only for a backend
  217. cat new_pg_options > $DATA_DIR/pg_options
  218. kill -HUP $backend_pid
  219. cat old_pg_options > $DATA_DIR/pg_options
  220. </programlisting>
  221. </para>
  222. </chapter>