Skip to content

Ensure channel-pool shutdown reports shutdown rather than timeout #4719

Description

@mdaigle

🤖

Describe the bug

Please verify that acquisitions interrupted by ChannelDbConnectionPool shutdown report shutdown rather than a pool timeout, and correct any paths that misclassify the failure.

This is a focused follow-up to #4714. PR #4718 addresses the wait-handle pool only.

Current evidence: ChannelDbConnectionPool.GetInternalConnection already catches ChannelClosedException and throws InvalidOperationException with SQL_ConnectionPoolShutDown: “The connection pool has been shut down.” Its OperationCanceledException handler reports ADP.PooledOpenTimeout(). A channel-pool timeout misclassification has not yet been reproduced.

Source: ChannelDbConnectionPool.cs.

To reproduce

No confirmed channel-specific repro yet. Please add deterministic coverage with Switch.Microsoft.Data.SqlClient.UseConnectionPoolV2 enabled:

  1. Hold all available pool capacity and park another acquisition.
  2. Call ClearPool or ClearAllPools before its connection timeout expires.
  3. Verify the acquisition reports shutdown, not a pool timeout.

Cover both Open and OpenAsync, including shutdown while an async acquisition is scheduled but has not started. Keep separate coverage for genuine timeout expiration and caller cancellation.

The workload in #4714 can also guide investigation with the channel-pool switch enabled.

Expected behavior

  • Shutdown-interrupted acquisitions report the existing shutdown-specific error rather than suggesting pool exhaustion or an elapsed timeout.
  • Genuine timeouts retain their timeout error.
  • Caller cancellation retains its existing behavior.

If all relevant paths already behave correctly, add regression coverage and document that finding rather than changing the error handling unnecessarily.

Further technical details

Microsoft.Data.SqlClient version: current source at 153f8793e6672816ce6a0652fdae4ea21708b5ad; affected released versions not established.
.NET target: not yet reproduced.
SQL Server version: not yet reproduced.
Operating system: not yet reproduced.

Additional context

Related: #4302, #4714, #4718.

Scope is error classification and regression coverage only. Allowing admitted channel-pool acquisitions to finish after shutdown, adding replacement-pool retries, and redesigning channel lifetime are out of scope.

Activity

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

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions