summaryrefslogtreecommitdiff
path: root/doc/src/sgml/connection-pooling.sgml
blob: f6ebb773ca3f8211ceb4e68235fe195a5dc1d520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
<!-- doc/src/sgml/config.sgml -->

<sect1 id="runtime-config-connection-pooling">
 <title>Connection Pooling</title>

 <para>
  <productname>Pgpool-II</productname> maintains established
  connections to the PostgreSQL servers, and reuses them whenever a
  new connection with the same properties (i.e. user name, database,
  protocol version) comes in. It reduces the connection overhead,
  and improves system's overall throughput.
 </para>

 <sect2 id="runtime-config-connection-pooling-settings">
  <title>Connection Pooling Settings</title>

  <variablelist>

   <varlistentry id="guc-connection-cache" xreflabel="connection_cache">
    <term><varname>connection_cache</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>connection_cache</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Caches connections to backends when set to on. Default is on.
      <emphasis>However, connections to <literal>template0</>, <literal>template1</>,
       <literal>postgres</> and <literal>regression</> databases are not cached even if
       <varname>connection_cache</> is on.</emphasis>
     </para>
     <para>
      You need to restart <productname>Pgpool-II</productname>
      if you change this value.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-max-pool" xreflabel="max_pool">
    <term><varname>max_pool</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>max_pool</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      The maximum number of cached connections
      in each <productname>Pgpool-II</productname> child
      process.  <productname>Pgpool-II</productname> reuses the
      cached connection if an incoming connection is connecting
      to the same database with the same user name and the same
      run-time parameters.  If not,
      <productname>Pgpool-II</productname> creates a new
      connection to the backend.  If the number of cached
      connections exceeds max_pool, the oldest connection will
      be discarded, and uses that slot for the new connection.
     </para>
     <para>
      Default value is 4. Please be aware that the number of
      connections from <productname>Pgpool-II</productname> processes to the backends may reach
      num_init_children * max_pool in total.
     </para>
     <para>
      This parameter can only be set at server start.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-listen-backlog-multiplier" xreflabel="listen_backlog_multiplier">
    <term><varname>listen_backlog_multiplier</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>listen_backlog_multiplier</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Specifies the length of connection queue from frontend to
      <productname>Pgpool-II</productname>. The queue length (actually
      <literal>"backlog"</literal> parameter of <literal>listen()</literal>
      system call) is defined as
      <varname>listen_backlog_multiplier</varname> * <xref linkend="guc-num-init-children">.
     </para>
     <note>
      <para>
       Some systems have the upper limit of the backlog parameter of
       <literal>listen()</literal> system call.
       See <xref linkend="guc-num-init-children"> for more details.
      </para>
     </note>
     <para>
      Default is 2.
     </para>
     <para>
      This parameter can only be set at server start.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-serialize-accept" xreflabel="serialize_accept">
    <term><varname>serialize_accept</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>serialize_accept</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      When set to on, <productname>Pgpool-II</productname> enables the serialization
      on incoming client connections.
      Without serialization the OS kernel wakes up all of the <productname>
       Pgpool-II</productname> children processes to execute <literal>accept()</> and one of them
      actually gets the incoming connection. The problem here is, because so my child
      process wake up at a same time, heavy context switching occurs and the
      performance is affected.
     </para>
     <para>
      This phenomena is a well known classic problem called
      "the thundering herd problem". This can be solved by the
      serialization of the <literal>accept()</> calls, so that only one
      <productname>Pgpool-II</productname> process gets woken up
      for incoming connection to execute the <literal>accept()
      </literal>.
     </para>

     <para>
      But serialization has its own overheads, and it is recommended
      to be used only with the larger values of <xref linkend="guc-num-init-children">.
       For the small number of <xref linkend="guc-num-init-children">,
	the serialize accept can degrade the performance because of
	serializing overhead.
     </para>

     <note>
      <para>
       It is recommended to do a benchmark before deciding whether to use
       <varname>serialize_accept</varname> or not, because the correlation
       of <xref linkend="guc-num-init-children"> and <varname>serialize_accept</varname>
	can be different on different environments.
      </para>
     </note>

     <example id="example-serialize-accept-pgbench">
      <title>Using pgbench to decide if serialize_accept should be used</title>
      <para>
       To run the <command>pgbench</command> use the following
       command.
       <programlisting>
	pgbench -n -S -p 9999 -c 32 -C -S -T 300 test
       </programlisting>
       Here, <literal>-C</literal> tells <command>pgbench</command> to connect
       to database each time a transaction gets executed. <literal>-c 32</literal>
       specifies the number of the concurrent sessions to <productname>Pgpool-II</productname>.
       You should change this according to your system's requirement.
       After <command>pgbench</command> finishes, check the number from
       "including connections establishing".
      </para>
     </example>

     <note>
      <para>
       When <xref linkend="guc-child-life-time"> is enabled, <varname>serialize_accept</varname>
	has no effect. Make sure that you set <xref linkend="guc-child-life-time"> to 0 if you intend
	 to turn on the <varname>serialize_accept</varname>.
	 And if you are worried about <productname>Pgpool-II</productname> process memory leaks
	 or whatever potential issue, you could use <xref linkend="guc-child-max-connections"> instead.
	  This is purely an implementation limitation and may be removed in the future.
      </para>
     </note>

     <para>
      Default is off.
     </para>
     <para>
      This parameter can only be set at server start.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-child-life-time" xreflabel="child_life_time">
    <term><varname>child_life_time</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>child_life_time</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Specifies the time in seconds to terminate
      a <productname>Pgpool-II
      </productname> child process if it remains idle because no client is connecting to it.
      The new child process
      is immediately spawned by <productname>Pgpool-II</productname> when it
      is terminated because of <varname>child_life_time</varname>.
      <varname>child_life_time</varname> is a measure to prevent the
      memory leaks and other unexpected errors in <productname>Pgpool-II

      </productname> children.
     </para>
     <note>
      <para>
       <varname>child_life_time</varname> does not apply to
       processes that have not accepted any connection yet.
      </para>
     </note>
     <note>
      <para>
       <xref linkend="guc-serialize-accept"> becomes ineffective when
	<varname>child_life_time</varname> is enabled.
      </para>
     </note>
     <para>
      Default is 300 (5 minutes) and setting it to 0 disables the feature.
     </para>
     <para>
      This parameter can only be set at server start.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-client-idle-limit" xreflabel="client_idle_limit">
    <term><varname>client_idle_limit</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>client_idle_limit</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Specifies the time in seconds to disconnect a client if it remains idle
      since the last query.
      This is useful for preventing the <productname>Pgpool-II</productname>
      children from being occupied by a lazy clients or broken TCP/IP
      connection between client and <productname>Pgpool-II</productname>.
     </para>
     <note>
      <para>
       <varname>client_idle_limit</varname> is ignored in
       the second stage of online recovery.
      </para>
     </note>
     <para>
      The default is 0, which turns off the feature.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
       this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-child-max-connections" xreflabel="child_max_connections">
    <term><varname>child_max_connections</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>child_max_connections</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Specifies the lifetime of a <productname>Pgpool-II</productname>
      child process in terms of the number of client connections it can receive.
      <productname>Pgpool-II</productname> will terminate the child process
      after it has served <varname>child_max_connections</varname> client
      connections and will immediately spawn a new child process to take its place.
     </para>
     <para>
      <varname>child_max_connections</varname> is useful on a very busy server,
      where <xref linkend="guc-child-life-time"> and <xref linkend="guc-connection-life-time">
	never gets triggered. It is also useful to prevent the <productname>PostgreSQL</> servers from getting
	too big.
     </para>
     <para>
      The default is 0, which turns off the feature.
     </para>
     <para>
      This parameter can only be set at server start.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-connection-life-time" xreflabel="connection_life_time">
    <term><varname>connection_life_time</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>connection_life_time</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Specifies the time in seconds to terminate the cached connections
      to the <productname>PostgreSQL</> backend. This serves as the cached connection expiration time.
     </para>
     <para>
      If a client connects to the process which holds the cached
      connections, a calculation on
      the <varname>connection_life_time</varname> is not performed
      until the client disconnects. Thus it is possible that the cached
      connections are kept for longer time than this value. To avoid
      this, it is recommended to set shorter value
      to <xref linkend="guc-client-idle-limit">.
     </para>
     <para>
      The default is 0, which means the cached connections will not be
      disconnected.
     </para>
     <para>
      This parameter can only be set at server start.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-reset-query-list" xreflabel="reset_query_list">
    <term><varname>reset_query_list</varname> (<type>string</type>)
     <indexterm>
      <primary><varname>reset_query_list</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Specifies the <acronym>SQL</acronym> commands to be sent to reset the backend connection
      when exiting the user session. Multiple commands can be specified by delimiting each
      by <literal>";"</literal>.
     </para>

     <para>
      The available commands differ among <productname>PostgreSQL</> versions.
      Below are some recommended settings for <varname>reset_query_list</varname>
      on different <productname>PostgreSQL</> versions.
      Note, however, that <literal>ABORT</literal> command should be always included.
     </para>

     <table id="reset-query-list-suggestions-table">
      <title>Recommended setting for <varname>reset_query_list</varname>
       on different PostgreSQL versions</title>
      <tgroup cols="2">
       <thead>
	<row>
	 <entry>PostgreSQL version</entry>
	 <entry>reset_query_list</entry>
	</row>
       </thead>

       <tbody>
	<row>
	 <entry>7.1 or earlier</entry>
	 <entry><literal>'ABORT'</literal></entry>
	</row>

	<row>
	 <entry>7.2 to 8.2</entry>
	 <entry><literal>'ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT'</literal></entry>
	</row>

	<row>
	 <entry>8.3 or later</entry>
	 <entry><literal>'ABORT; DISCARD ALL'</literal></entry>
	</row>

       </tbody>
      </tgroup>
     </table>

     <note>
      <para>
       <literal>"ABORT"</literal> is not issued when not in a transaction block for 7.4 or later
       <productname>PostgreSQL</> versions.
      </para>
     </note>
     <para>
      Default is <literal>'ABORT; DISCARD ALL'</literal>.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

  </variablelist>
 </sect2>
</sect1>

<sect1 id="runtime-config-logging">
 <title>Error Reporting and Logging</title>

 <sect2 id="runtime-config-logging-where-to-log">
  <title>Where To Log</title>

  <variablelist>

   <varlistentry id="guc-log-destination" xreflabel="log_destination">
    <term><varname>log_destination</varname> (<type>string</type>)
     <indexterm>
      <primary><varname>log_destination</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      <productname>Pgpool-II</productname> supports two destinations
      for logging the <productname>Pgpool-II</productname> messages.
      The supported log destinations are <literal>stderr</literal>
      and <literal>syslog</literal>. You can also set this parameter to a list
      of desired log destinations separated by commas if you want the log messages
      on the multiple destinations.
      <programlisting>
       #for example to log on both syslog and stderr
       log_destination = 'syslog,stderr'
      </programlisting>
      The default is to log to <literal>stderr</literal> only.
     </para>
     <note>
      <para>
       On some systems you will need to alter the configuration of your
       system's <application>syslog</application> daemon in order to make use of the
       <literal>syslog</literal> option
       for <varname>log_destination</varname>. <productname>Pgpool-II</productname>
       can log to <application>syslog</application> facilities LOCAL0 through LOCAL7
       (see <xref linkend="guc-syslog-facility">), but the default
	<application>syslog</application>
	configuration on most platforms will discard all such messages.
	You will need to add something like:
	<programlisting>
	 local0.*    /var/log/pgpool.log
	</programlisting>
	to the syslog daemon's configuration file to make it work.
      </para>
     </note>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-logging-collector" xreflabel="logging_collector">
    <term><varname>logging_collector</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>logging_collector</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
	 This parameter enables the logging collector, which is a background process that captures
	 log messages sent to stderr and redirects them into log files.
     </para>
	 <note>
	 <para>
	 It is possible to log to stderr without using the logging collector; the log messages will
	 just go to wherever the server's stderr is directed. However, that method is only suitable
	 for low log volumes, since it provides no convenient way to rotate log files.
	 </para>
	 </note>
	 <para>
	 This parameter can only be set at the Pgpool-II start.
	 </para>
     <para>
      <varname>logging_collector</varname> is not available prior to
      <productname>Pgpool-II </productname><emphasis>V4.2</emphasis>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-directory" xreflabel="log_directory">
    <term><varname>log_directory</varname> (<type>string</type>)
     <indexterm>
      <primary><varname>log_directory</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
	 When <xref linkend="guc-logging-collector"> is enabled, this parameter determines
	 the directory in which log files will be created.
     </para>
	 <para>The default is <literal>/tmp/pgpool_logs</literal>.</para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>

    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-filename" xreflabel="log_filename">
    <term><varname>log_filename</varname> (<type>string</type>)
     <indexterm>
      <primary><varname>log_filename</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
	 When <xref linkend="guc-logging-collector"> is enabled, this parameter sets the
	 file names of the created log files. The value is treated as a
	 <literal>strftime</literal> pattern, so %-escapes can be used to specify time-varying
	 file names.
	 The supported %-escapes are similar to those listed in the Open Group's
	 <ulink url="https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html">strftime</ulink>specification.
     </para>
	 <para>
	 If you specify a file name without escapes, you should plan to use a log rotation
	 utility to avoid eventually filling the entire disk.
	 </para>
	 <para>
	 The default is <literal>pgpool-%Y-%m-%d_%H%M%S.log</literal>.
	 </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-file-mode" xreflabel="log_file_mode">
    <term><varname>log_file_mode</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>log_file_mode</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
	 This parameter sets the permissions for log files when <xref linkend="guc-logging-collector">
	 is enabled. The parameter value is expected to be a numeric mode specified in the format
	 accepted by the <literal>chmod</literal> and <literal>umask</literal> system calls.
	 </para>

	 <note>
	 <para>
	 To use the customary octal format the number must start with a 0 (zero).
	 </para>
	 </note>

     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-rotation-age" xreflabel="log_rotation_age">
    <term><varname>log_rotation_age</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>log_rotation_age</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
	 When <xref linkend="guc-logging-collector"> is enabled, this parameter determines
	 the maximum amount of time to use an individual log file, after which a new log
	 file will be created. If this value is specified without units,
	 it is taken as minutes. The default is 24 hours.
     </para>
	 <para>
	 Set to zero to disable time-based creation of new log files.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-rotation-size" xreflabel="log_rotation_size">
    <term><varname>log_rotation_size</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>log_rotation_size</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
	 When <xref linkend="guc-logging-collector"> is enabled, this parameter determines
	 the maximum size of an individual log file. After this many kilobytes have been
	 emitted into a log file, a new log file will be created.
     </para>
	 <para>
	 Set to zero to disable size-based creation of new log files.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-truncate-on-rotation" xreflabel="log_truncate_on_rotation">
    <term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_truncate_on_rotation</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
	 When <xref linkend="guc-logging-collector"> is enabled,
	 this parameter will cause <productname>Pgpool-II</> to truncate (overwrite),
	 rather than append to, any existing log file of the same name.
	 However, truncation will occur only when a new file is being opened due to
	 time-based rotation, not during the startup or size-based rotation.
	 When off, pre-existing files will be appended to in all cases.
	 For example, using this setting in combination with a <xref linkend="guc-log-filename">
	 like pgpool-%H.log would result in generating twenty-four hourly log
	 files and then cyclically overwriting them.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-syslog-facility" xreflabel="syslog_facility">
    <term><varname>syslog_facility</varname> (<type>enum</type>)
     <indexterm>
      <primary><varname>syslog_facility</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      See also the documentation of your system's syslog daemon.
      When logging to <application>syslog</application> is enabled,
      this parameter determines the <application>syslog</application>
      <literal>"facility"</literal> to be used.
      You can choose from <literal>LOCAL0</>, <literal>LOCAL1</>,
      <literal>LOCAL2</>, <literal>LOCAL3</>, <literal>LOCAL4</>,
      <literal>LOCAL5</>, <literal>LOCAL6</>, <literal>LOCAL7</>;
      the default is <literal>LOCAL0</>.
      See also the documentation of your system's <application>syslog</> daemon.
     </para>

     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-syslog-ident" xreflabel="syslog_ident">
    <term><varname>syslog_ident</varname> (<type>string</type>)
     <indexterm>
      <primary><varname>syslog_ident</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      When logging to <application>syslog</> is enabled, this parameter determines
      the program name used to identify <productname>Pgpool-II</productname>
      messages in <application>syslog</> logs. The default is <literal>pgpool</literal>.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

  </variablelist>
 </sect2>

 <sect2 id="runtime-config-logging-when-to-log">
  <title>When To Log</title>

  <variablelist>

   <varlistentry id="guc-client-min-messages" xreflabel="client_min_messages">
    <term><varname>client_min_messages</varname> (<type>enum</type>)
     <indexterm>
      <primary><varname>client_min_messages</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Controls which minimum message levels are sent to the client.
      Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
      <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>,
      <literal>LOG</>, <literal>NOTICE</>, <literal>WARNING</> and
      <literal>ERROR</>. Each level includes
      all the levels that follow it. The default is <literal>NOTICE</>.
     </para>

     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
       this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-min-messages" xreflabel="log_min_messages">
    <term><varname>log_min_messages</varname> (<type>enum</type>)
     <indexterm>
      <primary><varname>log_min_messages</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      The default is WARNING.
      Controls which minimum message levels are emitted to log.
      Valid values are <literal>DEBUG5</>, <literal>DEBUG4</>,
      <literal>DEBUG3</>, <literal>DEBUG2</>, <literal>DEBUG1</>,
      <literal>INFO</>, <literal>NOTICE</>, <literal>WARNING</>,
      <literal>ERROR</>, <literal>LOG</>, <literal>FATAL</>,
      and <literal>PANIC</>.
      Each level includes all the levels that follow it.
      The default is <literal>WARNING</>.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
       this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

  </variablelist>
 </sect2>

 <sect2 id="runtime-config-logging-what-to-log">
  <title>What To Log</title>

  <variablelist>

   <varlistentry id="guc-log-statement" xreflabel="log_statement">
    <term><varname>log_statement</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_statement</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Setting to on, prints all SQL statements to the log.
     </para>

     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
       this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-per-node-statement" xreflabel="log_per_node_statement">
    <term><varname>log_per_node_statement</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_per_node_statement</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Similar to <xref linkend="guc-log-statement">, except that it print the
       logs for each DB node separately. It can be useful to make sure that
       replication or load-balancing is working.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
       this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-notice-per-node-statement" xreflabel="notice_per_node_statement">
    <term><varname>notice_per_node_statement</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>notice_per_node_statement</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Similar to <xref linkend="guc-log-per-node-statement">, except
      that it prints the statement logs for each DB node separately as
      a NOTICE message. With the
      default <xref linkend="guc-client-min-messages"> setting (that
      is NOTICE), the log message will be printed on client's terminal
      as well. This is convenient for clients because it does not need
      to access <productname>Pgpool-II</productname> log file.  Note
      that
      unlike <xref linkend="guc-log-per-node-statement">, <xref linkend="guc-notice-per-node-statement">
      does not print internal queries, (e.g., system catalog inquiry).
      This is because this feature is designed to be used for testing
      as well. As internal queries tend to be non-deterministic,
      printing them in testing is not helpful. For the same reason,
      backend process id is not printed.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
      this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-client-messages" xreflabel="log_client_messages">
    <term><varname>log_client_messages</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_client_messages</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Setting to on, prints client messages to the log.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
       this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-backend-messages" xreflabel="log_backend_messages">
    <term><varname>log_backend_messages</varname> (<type>enum</type>)
     <indexterm>
      <primary><varname>log_backend_messages</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Setting to <literal>terse</literal>
      or <literal>verbose</literal>, prints backend messages to the
      log.  With <literal>terse</literal> the number of same kind of
      messages are recorded and is printed when different kind of
      messages is sent. Below is an example.
      <programlisting>
       LOG:  last DataRow message from backend 0 repeated 10 times
      </programlisting>
      Thus the log will not be printed if the process corresponding to
      the session is killed. If you want to print the log even in this
      case, use <literal>verbose</literal> option. Note that with the
      option each repeated message is printed and lots of log lines
      are printed. The default is <literal>none</literal>, which
      disables printing log messages from backend.
     </para>
     <para>
      This parameter can be changed by reloading
      the <productname>Pgpool-II</> configurations.  You can also
      use <xref linkend="SQL-PGPOOL-SET"> command to alter the value
      of this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-hostname" xreflabel="log_hostname">
    <term><varname>log_hostname</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_hostname</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Setting to on, prints the hostname instead of IP address
      in the <command>ps</> command result, and connection logs
      (when <xref linkend="guc-log-connections"> is on).
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-connections" xreflabel="log_connections">
    <term><varname>log_connections</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_connections</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Setting to on, prints all client connections from to the log.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-disconnections" xreflabel="log_disconnections">
    <term><varname>log_disconnections</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_disconnections</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Setting to on, prints all client connection terminations to the log.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-pcp-processes" xreflabel="log_pcp_processes">
    <term><varname>log_pcp_processes</varname> (<type>boolean</type>)
     <indexterm>
      <primary><varname>log_pcp_processes</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Setting to on, enable logging about normal PCP Process
      fork and exit status. Default is on.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity">
    <term><varname>log_error_verbosity</varname> (<type>enum</type>)
     <indexterm>
      <primary><varname>log_error_verbosity</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      Controls the amount of detail emitted for each message that is logged.
      Valid values are <literal>TERSE</>, <literal>DEFAULT</>, and <literal>VERBOSE</>,
      each adding more fields
      to displayed messages. <literal>TERSE</> excludes the logging of <literal>DETAIL</>,
      <literal>HINT</>, <literal>QUERY</>
      and <literal>CONTEXT</> error information.
     </para>
     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
       this parameter for a current session.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="guc-log-line-prefix" xreflabel="log_line_prefix">
    <term><varname>log_line_prefix</varname> (<type>string</type>)
     <indexterm>
      <primary><varname>log_line_prefix</varname> configuration parameter</primary>
     </indexterm>
    </term>
    <listitem>
     <para>
      This is a <function>printf</>-style string that is output at the beginning of
      each log line.
      <literal>%</literal> characters begin <quote>escape sequences</> that are replaced
      with information outlined below.
      All unrecognized escapes are ignored. Other characters are copied straight to
      the log line. Default is '%m: %a pid %p: ', which prints timestamp, application name and process id.
     </para>

     <table id="log-line-prefix-table">
      <title>log_line_prefix escape options</title>

      <tgroup cols="2">
       <thead>
	<row>
	 <entry>Escape</entry>
	 <entry>Effect</entry>
	</row>
       </thead>

       <tbody>
	<row>
	 <entry>%a</entry>
	 <entry>
	  Application name. The initial value for child (session
	  process) is "child". If Clients set application name
	  (either in the startup message or by using SET command),
	  application name will be changed accordingly. In other types
	  of process, application name is a hard coded string. see
	  <xref linkend="application-name-table">.
	 </entry>
	</row>

	<row>
	 <entry>%p</entry>
	 <entry>Process ID (PID)</entry>
	</row>

	<row>
	 <entry>%P</entry>
	 <entry>Process name</entry>
	</row>

	<row>
	 <entry>%t</entry>
	 <entry>Time stamp without milliseconds</entry>
	</row>

	<row>
	 <entry>%m</entry>
	 <entry>Time stamp with milliseconds</entry>
	</row>

	<row>
	 <entry>%d</entry>
	 <entry>Database name</entry>
	</row>

	<row>
	 <entry>%u</entry>
	 <entry>User name</entry>
	</row>

	<row>
	 <entry>%l</entry>
	 <entry>Log line number for each process</entry>
	</row>

	<row>
	 <entry>%%</entry>
	 <entry>'%' character</entry>
	</row>

       </tbody>
      </tgroup>
     </table>

     <table id="application-name-table">
      <title>application names in various process</title>

      <tgroup cols="2">
       <thead>
	<row>
	 <entry>Process type</entry>
	 <entry>application name</entry>
	</row>
       </thead>

       <tbody>

	<row>
	 <entry>main</entry>
	 <entry>main</entry>
	</row>

	<row>
	 <entry>child</entry>
	 <entry>child</entry>
	</row>

	<row>
	 <entry>streaming replication delay check worker</entry>
	 <entry>sr_check_worker</entry>
	</row>

	<row>
	 <entry>watchdog heart beat sender</entry>
	 <entry>heart_beat_sender</entry>
	</row>

	<row>
	 <entry>watchdog heart beat receiver</entry>
	 <entry>heart_beat_receiver</entry>
	</row>

	<row>
	 <entry>watchdog</entry>
	 <entry>watchdog</entry>
	</row>

	<row>
	 <entry>watchdog life check</entry>
	 <entry>life_check</entry>
	</row>

	<row>
	 <entry>follow primary child</entry>
	 <entry>follow_child</entry>
	</row>

	<row>
	 <entry>watchdog utility</entry>
	 <entry>watchdog_utility</entry>
	</row>

	<row>
	 <entry>pcp main</entry>
	 <entry>pcp_main</entry>
	</row>

	<row>
	 <entry>pcp child</entry>
	 <entry>pcp_child</entry>
	</row>

	<row>
	 <entry>health check process</entry>
	 <entry>health_check%d (%d is replaced with backend node id)</entry>
	</row>

	<row>
	 <entry>logger process</entry>
	 <entry>logger (Note that the application name "logger" will not be output to the log file managed by logger process)</entry>
	</row>

       </tbody>
      </tgroup>
     </table>

     <para>
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
     </para>
    </listitem>
   </varlistentry>

  </variablelist>
 </sect2>
</sect1>