Skip to content

[Question] Troubleshooting idle connections in cvat_db #9147

@mmoyano-sigmacognition

Description

@mmoyano-sigmacognition

Hi,

I recently opened this issue due to server availability problems, when using CVAT version 2.11.2, caused by reaching the maximum number of connections (200, which I increased to 500). After successfully monitoring all the connected IPs, I proceeded to check active connections to the cvat_db, and noticed many idle connections, like the ones shown below:

psql cvat
SELECT pid, usename, datname, state, query, state_change FROM pg_stat_activity order by state_change;
pid | usename | datname | state | query | state_change
----+----------+----------+-----+-------+--------------
... | anonymized | cvat | idle | SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 21 | 2025-02-24 08:19:29.901414+00

... | anonymized | cvat | idle | SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 21 | 2025-02-24 07:36:58.635467+00

... | anonymized | cvat | idle | SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 21 | 2025-02-21 18:53:09.882007+00

Although I show just three connections here, there are 53 connections in total, and only one of them is active. Currently, one user is labeling, which is why there should be at least one active connection.

When I run the query above, the following result is printed::

SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 LIMIT 21;
 id | password | last_login | is_superuser | username | first_name | last_name | email | is_staff | is_active | date_joined      
---+-----------+----------+--------------+-----------+------------+-----------+------+--------+---------+-------------
  1 | anonymized_pwd | 2025-02-21 18:43:35.628501+00 | t | anonymized_user |  |  |  | t | t | 2024-04-02 08:14:00.765091+00
(1 row)

Could you help me understand the origin of these idle connections? What could be causing them to stay in an idle state? Any guidance on how to address this issue would be greatly appreciated.

Thanks in advance. Cheers,
Manuel

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