Skip to content

Consider exposing NpgsqlDataSource.Clear() publicly #5902

Description

@roji

In npgsql/efcore.pg#3326, EFCore.PG drops a database via DROP DATABASE test WITH (FORCE); this obviously causes any pooled connections to become broken. To prevent future exceptions, the provider calls NpgsqlConnection.ClearAllPools(); this works for legacy mode, but if a data source is in use, it is not cleared.

We do have Clear() on NpgsqlDataSource, but it isn't exposed publicly - it's only used from dispose. However, dispose makes the data source unusable, which is not what's desired here - the point is only to get rid of all existing idle connections, since we know that they're broken.

Activity

  1. added this to the 9.0.0 milestone on Oct 27, 2024
  2. self-assigned this
    on Oct 27, 2024
  3. added a commit that references this issue on Oct 28, 2024
    c0fd0d4
  4. added theissue type on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions