[pgpool-general: 6915] Re: Pgpool postgresql - Idle connections close problem

Radosław Szczygieł radoslaw.szczygiel at interia.pl
Thu Mar 5 20:37:31 JST 2020

This is simple python code that make insert 10 times each time making a new connection.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.script:#!/usr/bin/pythonimport osimport sysimport psycopg2for x in range(1,10):    #ustawienia polaczenia i nawiazanie polaczenia    conn = psycopg2.connect("host=pgpool port=9999 dbname=test user=test password=test")    cur = conn.cursor()    sql="INSERT INTO test1 values (1,1)"    try:        cur.execute(sql)        conn.commit()    except:        print("BLAD - Nie powiodlo sie wstawianie zapytania %s" % sql)    else:        print("Wstawiono rekord: %s" % sql)    conn.close()--Pozdrawiam
Radosław SzczygiełTemat: Re: [pgpool-general: 6901] Pgpool postgresql - Idle connections close problemData: 2020-03-05 11:37Nadawca: "Bo Peng" Adresat: "Radosław Szczygieł" ; DW: pgpool-general at pgpool.net; > Hello,
> I want to reproduce this issue.
> Could you share the test program?
> On Wed, 04 Mar 2020 10:43:56 +0100
> Radosław Szczygieł  wrote:
> > 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 -
>  num_init_children = 300                                   # Number of concurrent sessions allowed                                   # (change requires restart)max_pool = 5                                   # Number of connection pool caches per connection                                   # (change requires 
>  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  &
>  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
>  slaw Szczygiel--PozdrawiamRadosław Szczygieł
> -- 
> Bo Peng 
> SRA OSS, Inc. Japan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.sraoss.jp/pipermail/pgpool-general/attachments/20200305/d050cc72/attachment-0001.html>

More information about the pgpool-general mailing list