Skip to content

[BUG] Idle connections evicted from Druid pool do not close underlying MySQL physical connections; orphan physical connections persist after app shutdown #6664

Open

Description

@jutbin

Database Type

mysql5.7

Database Version

mysql5.7

Druid Version

1.2.23

JDK Version

jdk8

Error SQL

When Druid connection pool evicts idle connections, only the connection object is removed from the pool, but the underlying physical TCP connection to MySQL remains open. I expect the physical database connection to be closed simultaneously when the idle connection gets evicted from the pool.
Additionally, there is an inconsistent behavior on application shutdown:
Right after the application starts, if I stop the program, all physical MySQL connections get closed properly.
However, after the application runs for a period of time, leftover physical MySQL connections can no longer be terminated when stopping the service.
My analysis: This issue occurs because those connections have already been evicted out of the pool beforehand. Logically, all physical MySQL connections belonging to the application should be fully closed once the application process exits, regardless of whether they were evicted from the pool earlier.

Testcase Code

No response

Stacktrace Info

No response

Error Info

No response

Activity

  1. hiSandog commented on Jul 8, 2026

    @hiSandog

    This should probably be covered at both eviction and shutdown boundaries. A regression test with a fake or instrumented physical connection could assert that idle eviction calls the underlying close path exactly once, and that application shutdown does not leave the same physical MySQL connection open after the pool object is gone.

  2. added a commit that references this issue on Aug 15, 2026
    3d23082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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