<div dir="ltr"><div>The problem is always in the last place you checked..</div><div><br></div><div>On the postgresql pg_hba I had a /32 row for my pgpool IP address for trusted connection and one old (due to prior tests) /8 row matching with pgpool address, so sometimes postgresql accepted connections (matching with the &quot;trust&quot; rule) and sometimes refused them (matching with the md5 connection), setting the server as down.</div><div><br></div><div>Thanks a lot!</div><div>Matteo M.</div><br><br><div class="gmail_quote"><div dir="ltr">Il giorno ven 26 ott 2018 alle ore 15:13 Bo Peng &lt;<a href="mailto:pengbo@sraoss.co.jp">pengbo@sraoss.co.jp</a>&gt; ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
It seems that authentication failed failed when pgpool issues pg_is_in_recovery() to backends<br>
to find primary node.<br>
<br>
How did you configure pool_passwd, pool_hba.conf and pg_hba.conf?<br>
<br>
<br>
On Wed, 24 Oct 2018 16:27:03 +0200<br>
Matteo Monesi &lt;<a href="mailto:matteo.monesi@carel.com" target="_blank">matteo.monesi@carel.com</a>&gt; wrote:<br>
<br>
&gt; Hi,<br>
&gt; <br>
&gt; I&#39;m new to pgpool and I&#39;m finding difficulties following the several guides<br>
&gt; I found on web.<br>
&gt; <br>
&gt; I have 3 debian servers, 1 for pgpool (v 4.0.0) and 2 for the two<br>
&gt; postgresql servers (v 10.5, one primary and one hot standby, using<br>
&gt; streaming replication).<br>
&gt; <br>
&gt; My pgpool can find the 2 nodes, but it mark both of them as standby.<br>
&gt;  node_id |  hostname   | port | status | lb_weight |  role   | select_cnt |<br>
&gt; load_balance_node | replication_delay | last_status_change<br>
&gt; ---------+-------------+------+--------+-----------+---------+------------+-------------------+-------------------+---------------------<br>
&gt;  0       | 10.50.0.230 | 5432 | up     | 0.500000  | standby | 0          |<br>
&gt; false             | 0                 | 2018-10-24 15:58:13<br>
&gt;  1       | 10.50.0.232 | 5432 | up     | 0.500000  | standby | 0          |<br>
&gt; true              | 0                 | 2018-10-24 15:58:13<br>
&gt; Executing manually SELECT pg_is_in_recovery(); on the 2 postgresql server I<br>
&gt; correctly obtain false for the primary and true for the standby.<br>
&gt; <br>
&gt; The connection to the 2 db works, I can send queries (with pgAdmin4) to<br>
&gt; pgpool and I can receive answer from both the DB (pgpool do balancing, so I<br>
&gt; can grow the 2 counter select_cnt).<br>
&gt; <br>
&gt; (I also tried with the previous pgpool version, 3.7.5, but I have a<br>
&gt; different problem: node 0 is always detected as up, node 1 is always down,<br>
&gt; don&#39;t mind which server I put as node 0 and node 1)<br>
&gt; <br>
&gt; I attach my pgpool config and the pgpool output.<br>
&gt; <br>
&gt; Any help is welcome!<br>
&gt; Thank you<br>
&gt; Matteo M.<br>
&gt; <br>
&gt; <br>
&gt; ---------------------------------------------------------------------<br>
&gt; pgpool.conf START -----------------------------------------------------<br>
&gt; listen_addresses = &#39;*&#39;<br>
&gt; port = 5432<br>
&gt; socket_dir = &#39;/var/run/postgresql&#39;<br>
&gt; <br>
&gt; pcp_listen_addresses = &#39;*&#39;<br>
&gt; pcp_port = 9898<br>
&gt; pcp_socket_dir = &#39;/var/run/postgresql&#39;<br>
&gt; listen_backlog_multiplier = 2<br>
&gt; serialize_accept = off<br>
&gt; <br>
&gt; <br>
&gt; backend_hostname0 = &#39;10.50.0.230&#39;<br>
&gt; backend_port0 = 5432<br>
&gt; backend_weight0 = 1<br>
&gt; backend_data_directory0 = &#39;/var/lib/postgresql/10/main&#39;<br>
&gt; backend_flag0 = &#39;ALLOW_TO_FAILOVER&#39;<br>
&gt; <br>
&gt; backend_hostname1 = &#39;10.50.0.232&#39;<br>
&gt; backend_port1 = 5432<br>
&gt; backend_weight1 = 1<br>
&gt; backend_data_directory1 = &#39;/var/lib/postgresql/10/main&#39;<br>
&gt; backend_flag1 = &#39;ALLOW_TO_FAILOVER&#39;<br>
&gt; <br>
&gt; enable_pool_hba = on<br>
&gt; pool_passwd = &#39;pool_passwd&#39;<br>
&gt; authentication_timeout = 60<br>
&gt; allow_clear_text_frontend_auth = off<br>
&gt; <br>
&gt; ssl = off<br>
&gt; #ssl_key = &#39;./server.key&#39;<br>
&gt; #ssl_cert = &#39;./server.cert&#39;<br>
&gt; #ssl_ca_cert = &#39;&#39;<br>
&gt; #ssl_ca_cert_dir = &#39;&#39;<br>
&gt; <br>
&gt; num_init_children = 32<br>
&gt; max_pool = 4<br>
&gt; <br>
&gt; child_life_time = 300<br>
&gt; child_max_connections = 0<br>
&gt; connection_life_time = 0<br>
&gt; client_idle_limit = 0<br>
&gt; <br>
&gt; log_destination = &#39;stderr&#39;<br>
&gt; log_line_prefix = &#39;%t: pid %p: &#39;   # printf-style string to output at<br>
&gt; beginning of each log line.<br>
&gt; log_connections = off<br>
&gt; log_hostname = off<br>
&gt; log_statement = off<br>
&gt; log_per_node_statement = off<br>
&gt; log_client_messages = off<br>
&gt; log_standby_delay = &#39;if_over_threshold&#39;<br>
&gt; <br>
&gt; syslog_facility = &#39;LOCAL0&#39;<br>
&gt; syslog_ident = &#39;pgpool&#39;<br>
&gt; log_error_verbosity = verbose<br>
&gt; client_min_messages = debug5<br>
&gt; log_min_messages = debug5<br>
&gt; <br>
&gt; pid_file_name = &#39;/var/run/postgresql/pgpool.pid&#39;<br>
&gt; logdir = &#39;/tmp&#39;<br>
&gt; <br>
&gt; connection_cache = on<br>
&gt; reset_query_list = &#39;ABORT; DISCARD ALL&#39;<br>
&gt; #reset_query_list = &#39;ABORT; RESET ALL; SET SESSION AUTHORIZATION DEFAULT&#39;<br>
&gt; <br>
&gt; replication_mode = off<br>
&gt; replicate_select = off<br>
&gt; insert_lock = off<br>
&gt; lobj_lock_table = &#39;&#39;<br>
&gt; <br>
&gt; replication_stop_on_mismatch = off<br>
&gt; failover_if_affected_tuples_mismatch = off<br>
&gt; <br>
&gt; load_balance_mode = on<br>
&gt; ignore_leading_white_space = on<br>
&gt; white_function_list = &#39;&#39;<br>
&gt; black_function_list = &#39;currval,lastval,nextval,setval&#39;<br>
&gt; black_query_pattern_list = &#39;&#39;<br>
&gt; database_redirect_preference_list = &#39;&#39;<br>
&gt; app_name_redirect_preference_list = &#39;&#39;<br>
&gt; allow_sql_comments = off<br>
&gt; disable_load_balance_on_write = &#39;transaction&#39;<br>
&gt; <br>
&gt; master_slave_mode = on<br>
&gt; master_slave_sub_mode = &#39;stream&#39;<br>
&gt; <br>
&gt; sr_check_period = 10<br>
&gt; sr_check_user = &#39;postgres&#39;<br>
&gt; sr_check_password = &#39;postgres&#39;<br>
&gt; sr_check_database = &#39;postgres&#39;<br>
&gt; delay_threshold = 10000000<br>
&gt; <br>
&gt; follow_master_command = &#39;&#39;<br>
&gt; <br>
&gt; health_check_period = 5<br>
&gt; health_check_timeout = 20<br>
&gt; health_check_user = &#39;postgres&#39;<br>
&gt; health_check_password = &#39;postgres&#39;<br>
&gt; health_check_database = &#39;postgres&#39;<br>
&gt; health_check_max_retries = 0<br>
&gt; health_check_retry_delay = 1<br>
&gt; connect_timeout = 10000<br>
&gt; <br>
&gt; failover_command = &#39;/etc/pgpool2/4.0.0/failover.sh %d %P %H replication<br>
&gt; /etc/postgresql/10/main/start_as_master&#39;<br>
&gt; failback_command = &#39;&#39;<br>
&gt; failover_on_backend_error = on<br>
&gt; detach_false_primary = off<br>
&gt; search_primary_node_timeout = 300<br>
&gt; <br>
&gt; recovery_user = &#39;postgres&#39;<br>
&gt; recovery_password = &#39;postgres&#39;<br>
&gt; recovery_1st_stage_command = &#39;recovery_1st_stage.sh&#39;<br>
&gt; recovery_2nd_stage_command = &#39;&#39;<br>
&gt; recovery_timeout = 90<br>
&gt; client_idle_limit_in_recovery = 0<br>
&gt; <br>
&gt; use_watchdog = off<br>
&gt; trusted_servers = &#39;&#39;<br>
&gt; ping_path = &#39;/bin&#39;<br>
&gt; wd_hostname = &#39;&#39;<br>
&gt; wd_port = 9000<br>
&gt; wd_priority = 1<br>
&gt; wd_authkey = &#39;&#39;<br>
&gt; wd_ipc_socket_dir = &#39;/tmp&#39;<br>
&gt; <br>
&gt; delegate_IP = &#39;&#39;<br>
&gt; if_cmd_path = &#39;/sbin&#39;<br>
&gt; if_up_cmd = &#39;ip addr add $_IP_$/24 dev eth0 label eth0:0&#39;<br>
&gt; if_down_cmd = &#39;ip addr del $_IP_$/24 dev eth0&#39;<br>
&gt; arping_path = &#39;/usr/sbin&#39;<br>
&gt; arping_cmd = &#39;arping -U $_IP_$ -w 1&#39;<br>
&gt; <br>
&gt; clear_memqcache_on_escalation = on<br>
&gt; wd_escalation_command = &#39;&#39;<br>
&gt; wd_de_escalation_command = &#39;&#39;<br>
&gt; failover_when_quorum_exists = on<br>
&gt; failover_require_consensus = on<br>
&gt; allow_multiple_failover_requests_from_node = off<br>
&gt; <br>
&gt; wd_monitoring_interfaces_list = &#39;&#39;  # Comma separated list of interfaces<br>
&gt; names to monitor.<br>
&gt; wd_lifecheck_method = &#39;heartbeat&#39;<br>
&gt; wd_interval = 10<br>
&gt; wd_heartbeat_port = 9694<br>
&gt; wd_heartbeat_keepalive = 2<br>
&gt; wd_heartbeat_deadtime = 30<br>
&gt; <br>
&gt; #heartbeat_destination0 = &#39;host0_ip1&#39;<br>
&gt; #heartbeat_destination_port0 = 9694<br>
&gt; #heartbeat_device0 = &#39;&#39;<br>
&gt; <br>
&gt; #heartbeat_destination1 = &#39;host0_ip2&#39;<br>
&gt; #heartbeat_destination_port1 = 9694<br>
&gt; #heartbeat_device1 = &#39;&#39;<br>
&gt; <br>
&gt; wd_life_point = 3<br>
&gt; wd_lifecheck_query = &#39;SELECT 1&#39;<br>
&gt; wd_lifecheck_dbname = &#39;template1&#39;<br>
&gt; wd_lifecheck_user = &#39;nobody&#39;<br>
&gt; wd_lifecheck_password = &#39;&#39;<br>
&gt; <br>
&gt; #other_pgpool_hostname0 = &#39;host0&#39;<br>
&gt; #other_pgpool_port0 = 5432<br>
&gt; #other_wd_port0 = 9000<br>
&gt; #other_pgpool_hostname1 = &#39;host1&#39;<br>
&gt; #other_pgpool_port1 = 5432<br>
&gt; #other_wd_port1 = 9000<br>
&gt; <br>
&gt; relcache_expire = 0<br>
&gt; relcache_size = 256<br>
&gt; check_temp_table = on<br>
&gt; check_unlogged_table = on<br>
&gt; <br>
&gt; memory_cache_enabled = off<br>
&gt; memqcache_method = &#39;shmem&#39;<br>
&gt; memqcache_memcached_host = &#39;localhost&#39;<br>
&gt; memqcache_memcached_port = 11211<br>
&gt; memqcache_total_size = 67108864<br>
&gt; memqcache_max_num_cache = 1000000<br>
&gt; memqcache_expire = 0<br>
&gt; memqcache_auto_cache_invalidation = on<br>
&gt; memqcache_maxcache = 409600<br>
&gt; memqcache_cache_block_size = 1048576<br>
&gt; memqcache_oiddir = &#39;/var/log/pgpool/oiddir&#39;<br>
&gt; white_memqcache_table_list = &#39;&#39;<br>
&gt; black_memqcache_table_list = &#39;&#39;<br>
&gt; <br>
&gt; ---------------------------------------------------------------------<br>
&gt; pgpool.conf END -----------------------------------------------------<br>
&gt; <br>
&gt; ---------------------------------------------------------------------<br>
&gt; pgpool.log -----------------------------------------------------<br>
&gt; The output is too long for an email (10k rows for 1 minute and half).<br>
&gt; It is available here:<br>
&gt; <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__drive.google.com_file_d_1fho2gh4JTBgjiY6bHlpUQAkB8tjS2ute_view-3Fusp-3Dsharing&amp;d=DwICAg&amp;c=z7ZdhQWiOKyPuOPFlqJIyw&amp;r=EozxJ07eZdUti5lcY_lysVNm7ciSa1TsqyT6WzR_9a8&amp;m=ORNMZLjeUsGnk07Sf8TZN7cY8U1Dmn4RYOq0qzfV2vk&amp;s=41KgNMhRNmKpkc8Dd6z0JMVVgEyfURMonRBJNd6TEyk&amp;e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=https-3A__drive.google.com_file_d_1fho2gh4JTBgjiY6bHlpUQAkB8tjS2ute_view-3Fusp-3Dsharing&amp;d=DwICAg&amp;c=z7ZdhQWiOKyPuOPFlqJIyw&amp;r=EozxJ07eZdUti5lcY_lysVNm7ciSa1TsqyT6WzR_9a8&amp;m=ORNMZLjeUsGnk07Sf8TZN7cY8U1Dmn4RYOq0qzfV2vk&amp;s=41KgNMhRNmKpkc8Dd6z0JMVVgEyfURMonRBJNd6TEyk&amp;e=</a><br>
<br>
<br>
-- <br>
Bo Peng &lt;<a href="mailto:pengbo@sraoss.co.jp" target="_blank">pengbo@sraoss.co.jp</a>&gt;<br>
SRA OSS, Inc. Japan<br>
<br>
</blockquote></div></div>