pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: maliansari.coder@gmail.com
Subject: BUG #18075: configuration variable idle_session_timeout not working as expected
Date: Tue, 29 Aug 2023 20:24:33 +0000
Message-ID: <18075-d8a1bf11f070743e@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18075
Logged by:          Muhammad Ali Ansari
Email address:      maliansari.coder@gmail.com
PostgreSQL version: 15.4
Operating system:   ubuntu 22.04
Description:        

I have set the idle_session_timeout variable as 60000 making it 60 seconds
as defined in documentation, I ran some queries in parallel and created
connections performed transactions and closed the connections, I checked the
connection count it was 27, from which 20 are the ones that were created
during execution of queries. The idle connections remain there even after 60
seconds timeout has passed. I am using following query to get the
connections and duration elapsed since state_change.

SELECT
    datname,
    pid,
    query,
    usename,
    client_addr,
    client_port,
    state,
    backend_xid,
    EXTRACT(MINUTE FROM (current_timestamp - state_change)) as duration 
FROM pg_stat_activity
WHERE
    datname = 'postgres'
    AND pid <> pg_backend_pid()
    AND state = 'idle'
ORDER BY
    backend_start DESC;

It gives following results:

 datname  | pid | query  | usename | client_addr | client_port | state |
backend_xid | duration
----------+-----+--------+---------+-------------+-------------+-------+-------------+----------
 postgres | 975 | COMMIT | apiuser | ::1         |       45748 | idle  |    
        |       28
 postgres | 974 | COMMIT | apiuser | ::1         |       45738 | idle  |    
        |       28
 postgres | 973 | COMMIT | apiuser | ::1         |       45724 | idle  |    
        |       28
 postgres | 972 | COMMIT | apiuser | ::1         |       45718 | idle  |    
        |       28
 postgres | 971 | COMMIT | apiuser | ::1         |       45714 | idle  |    
        |       28
 postgres | 970 | COMMIT | apiuser | ::1         |       45698 | idle  |    
        |       28
 postgres | 969 | COMMIT | apiuser | ::1         |       45696 | idle  |    
        |       28
 postgres | 968 | COMMIT | apiuser | ::1         |       45686 | idle  |    
        |       28
 postgres | 967 | COMMIT | apiuser | ::1         |       45670 | idle  |    
        |       28
 postgres | 966 | COMMIT | apiuser | ::1         |       45658 | idle  |    
        |       28
 postgres | 965 | COMMIT | apiuser | ::1         |       45648 | idle  |    
        |       28
 postgres | 964 | COMMIT | apiuser | ::1         |       45634 | idle  |    
        |       28
 postgres | 963 | COMMIT | apiuser | ::1         |       45620 | idle  |    
        |       28
 postgres | 962 | COMMIT | apiuser | ::1         |       45612 | idle  |    
        |       28
 postgres | 961 | COMMIT | apiuser | ::1         |       45608 | idle  |    
        |       28
 postgres | 960 | COMMIT | apiuser | ::1         |       45606 | idle  |    
        |       28
 postgres | 959 | COMMIT | apiuser | ::1         |       45592 | idle  |    
        |       28
 postgres | 958 | COMMIT | apiuser | ::1         |       45582 | idle  |    
        |       28
 postgres | 957 | COMMIT | apiuser | ::1         |       45574 | idle  |    
        |       28
 postgres | 956 | COMMIT | apiuser | ::1         |       45566 | idle  |    
        |       28
(20 rows)

As we can see, it shows that the time is way more than 1 minute now it is 28
minutes and they are still idle and still open in postgres and not
disconnected as expected.

If I get the configuration from following query:
select name, setting
from pg_settings
where
    name = 'idle_session_timeout'
    OR name = 'idle_in_transaction_session_timeout';

it returns this:

                name                                    | setting
--------------------------------------------------+---------
 idle_in_transaction_session_timeout | 60000
 idle_session_timeout                          | 60000
(2 rows)



view thread (13+ messages)  latest in thread

Message-ID: <18075-d8a1bf11f070743e@postgresql.org>
Permalink:  ../18075-d8a1bf11f070743e@postgresql.org/
Also on:    postgresql.org/message-id/18075-d8a1bf11f070743e@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, maliansari.coder@gmail.com
  Subject: Re: BUG #18075: configuration variable idle_session_timeout not working as expected
  In-Reply-To: <18075-d8a1bf11f070743e@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox