<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><div>This is simple python code that make insert 10 times each time making a new connection.<br>Every use this script make 10 connections through pgpool in postgres. I thought that using pgpool connection pooling new connections use cached connecions than close it.<br><br>script:<br><br>#!/usr/bin/python</div><div>import os<br>import sys<br>import psycopg2</div><div>for x in range(1,10):<br>    #ustawienia polaczenia i nawiazanie polaczenia<br>    conn = <a href="http://psycopg2.connect" target="_blank">psycopg2.connect</a>("host=<u><font color="#000120"><a href="http://pgpool.imgw.ad" target="_blank">pgpool</a> </font></u>port=9999 dbname=test user=test password=test")<br>    cur = <a href="http://conn.cursor" target="_blank">conn.cursor</a>()<br>    sql="INSERT INTO test1 values (1,1)"<br>    try:<br>        <a href="http://cur.execute" target="_blank">cur.execute</a>(sql)<br>        <a href="http://conn.commit" target="_blank">conn.commit</a>()<br>    except:<br>        print("BLAD - Nie powiodlo sie wstawianie zapytania %s" % sql)<br>    else:<br>        print("Wstawiono rekord: %s" % sql)<br>    <a href="http://conn.close" target="_blank">conn.close</a>()<br></div><style type="text/css">#icselection13 {width: 100% !important; height: 100% !important; padding-top: 0px !important; overflow: visible !important;}</style><br><br>--<br>Pozdrawiam <br>Radosław Szczygieł<div class="inpl-collapsed">Temat: Re: [pgpool-general: 6901] Pgpool postgresql - Idle connections close problem<br>Data: 2020-03-05 11:37<br>Nadawca: "Bo Peng" <pengbo><br>Adresat: "Radosław Szczygieł" <radoslaw.szczygiel>; <br>DW: pgpool-general@pgpool.net; <br><br><blockquote class="nxt-original-message-notrevealed" style="margin:0px;padding-left:1ex;border-left:1px solid #CCCCCC;"><pre>&gt; Hello,
&gt; 
&gt; I want to reproduce this issue.
&gt; Could you share the test program?
&gt; 
&gt; On Wed, 04 Mar 2020 10:43:56 +0100
&gt; Radosław Szczygieł  wrote:
&gt; 
&gt; &gt; Hi Pgpool team,I have a strange problem with hanging connections in postgresql or I don't know something. On postgres in pg_stat_activity I see many idle connections with "query_start" and "state_change" time from the previous day but they should be closed after 500 seconds (pgpool.conf settings).I made a test: create simply python code with loop making connect (using psycopg2), insert and close connection.  Each code call creates a lot of postgres connections and does not close them. I understand that "connection cache" works, but according to pgpool documentation, if the same connection is used, using the same database, username and password should use the existing connection??Did I something misunderstand of connection pooling? Why these old connections in postgresql that are longer than the times specified in pgpool.conf not closed ??My cluster is : 2 pgpool 4.1 (watchdog) + 2 postgresql 12 (master slave replication)pgpool.conf# - Concurrent session and pool size -
&gt;  num_init_children = 300                                   # Number of concurrent sessions allowed                                   # (change requires restart)max_pool = 5                                   # Number of connection pool caches per connection                                   # (change requires 
&gt;  restart)# - Life time -child_life_time = 600                # Pool exits after being idle for this many secondschild_max_connections = 1510                                   # Pool exits after receiving that many connections                                   # 0 means no exitconnection_life_time = 500                                   # Connection to backend closes after being idle for this many seconds  &amp;
&gt;  nbsp;                                # 0 means no closeclient_idle_limit = 300                                   # Client is disconnected after being idle for that many seconds                                   # (even inside an explicit transactions!)                                   # 0 means no disconnectionRegardsRado
&gt;  slaw Szczygiel--PozdrawiamRadosław Szczygieł
&gt; 
&gt; 
&gt; -- 
&gt; Bo Peng 
&gt; SRA OSS, Inc. Japan
&gt; </pre><br></blockquote><br><br></radoslaw.szczygiel></pengbo></div></body></html>