Skip to content

Hung (unclosed) old connections in idle status on the monitor from datanodes #1028

Description

@xinferum

Good afternoon.

pg_auto_failover version: 2.0

We found on several pg_auto_failover clusters the presence on the monitor server of suspended (probably unclosed from the data source) connections in the idle state:

datid	pid	usename		application_name		client_addr	backend_start			state_change			"now() - backend_start"	state	wait_event_type		wait_event	query
16521	272257	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-10 18:36:34.894 +0300	2024-01-10 18:36:36.296 +0300	8 days 14:36:37.430901	idle	Client			ClientRead	
16521	1195688	autoctl_node	pgautofailover_standby_3	10.9.10.13	2024-01-11 17:31:07.396 +0300	2024-01-11 17:31:09.309 +0300	7 days 15:42:04.928758	idle	Client			ClientRead	
16521	1714307	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-12 06:23:28.683 +0300	2024-01-12 06:23:30.095 +0300	7 days 02:49:43.641432	idle	Client			ClientRead	
16521	2335845	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-12 21:51:32.808 +0300	2024-01-12 21:51:34.295 +0300	6 days 11:21:39.51676	idle	Client			ClientRead	
16521	2882026	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-13 11:24:12.232 +0300	2024-01-13 11:24:14.003 +0300	5 days 21:49:00.093055	idle	Client			ClientRead	
16521	3127812	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-13 17:29:09.876 +0300	2024-01-13 17:29:11.251 +0300	5 days 15:44:02.448422	idle	Client			ClientRead	
16521	1580029	autoctl_node	pgautofailover_standby_3	10.9.10.13	2024-01-16 11:13:23.745 +0300	2024-01-16 11:13:25.066 +0300	2 days 21:59:48.579498	idle	Client			ClientRead	
16521	1938664	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-16 20:10:02.488 +0300	2024-01-16 20:10:04.085 +0300	2 days 13:03:09.836981	idle	Client			ClientRead	
16521	2140541	autoctl_node	pgautofailover_standby_3	10.9.10.13	2024-01-17 01:11:00.742 +0300	2024-01-17 01:11:02.403 +0300	2 days 08:02:11.58282	idle	Client			ClientRead	
16521	2275548	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-17 04:31:38.530 +0300	2024-01-17 04:31:40.203 +0300	2 days 04:41:33.794781	idle	Client			ClientRead	
16521	3986569	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-18 22:55:32.673 +0300	2024-01-18 22:55:34.221 +0300	10:17:39.651776		idle	Client			ClientRead	
16521	4040617	autoctl_node	pgautofailover_standby_3	10.9.10.13	2024-01-19 00:15:48.534 +0300	2024-01-19 00:15:50.478 +0300	08:57:23.790725		idle	Client			ClientRead	
16521	209392	autoctl_node	pgautofailover_standby_3	10.9.10.13	2024-01-19 09:13:11.821 +0300	2024-01-19 09:13:11.827 +0300	00:00:00.50327		idle	Client			ClientRead	LISTEN "state"
16521	209398	autoctl_node	pgautofailover_standby_1	10.9.10.11	2024-01-19 09:13:12.223 +0300	2024-01-19 09:13:12.228 +0300	00:00:00.101521		idle	Client			ClientRead	LISTEN "state"

In the example on one of the servers, we see two fresh connections that will work and close, but the rest weigh (some for several days) and do not close.
On one of the monitor servers, about 100+ connections have accumulated during its operation.

I understand that these are connections from the date of the year as part of the monitoring protocol https://pg-auto-failover.readthedocs.io/en/main/architecture.html#monitoring-protocol :

Data nodes periodically connect and run SELECT pgautofailover.node_active(…) to communicate their current state and obtain their goal state.

But, for some reason, not all connections are closed and remain stuck in idle status.
It is possible that the datanodes do not always close the connection during operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions