Skip to content

max_inactive_connection_lifetime does not close connections on unused pool connections #389

@albertferras

Description

@albertferras
  • asyncpg version: 0.18.2
  • PostgreSQL version: ---
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : no
  • Python version: 3.7
  • Platform: ---
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes
  • If you built asyncpg locally, which version of Cython did you use?: ---
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : yes

When a pool is created with a max_inactive_connection_lifetime defined, it will not close the connections for connections that are never used.
By looking at the code, the _setup_inactive_callback is only called when releasing a connection (that you've previously acquired). Shouldn't this method also be called after every new connection that has been established?

This is an issue for my use-case because we init the pool with a bigger min_size than what we need until our application cache is filled (after 10min we actually need less connections). If some of the connections were never used, they will stay connected forever and never killed.

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