'POSTGRES clients not shutting connections down

The clients of a postgres server I am dealing with at the moment never explicitly close the connections and I am wondering what repercussions that might have.

However, if I run a lot of queries without closing the underlying connection the SQL:

SELECT pid, client_addr, client_hostname, client_port, state FROM pg_stat_activity;

Returns me:

cc=# SELECT pid, client_addr, client_hostname, client_port, state FROM pg_stat_activity;

 pid | client_addr | client_hostname | client_port | state
-----+-------------+-----------------+-------------+--------
  69 |             |                 |             |
  71 |             |                 |             |
 297 | 172.17.0.1  |                 |       58434 | active
  67 |             |                 |             |
  66 |             |                 |             |
  68 |             |                 |             |
(6 rows)

That does not show a few rows, in fact it only shows the row describing the connection from which the query was issued.

To be fair I'd expect a lot more rows in there as I've run a plethora of requests, but I wonder if some permissions is needed or my query is correct at all.

The clients leave plenty of TCP sockets in TIME_WAIT - hence I'd expect the same in the server.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source