Skip to content

Improve error reporting when an application fails to obtain a connection from the pool #3545

Description

@David-Engel

Captured from a discussion with a support engineer.

Is your feature request related to a problem? Please describe.

When an application uses connection pooling and is running at the pool's capacity (max connections), there are instances where the error from the connection pool can hide the underlying cause of a failure to obtain a connection from the pool.

Obtaining a connection from the pool is done in the context of a timeout. If the request times out, the pool throws a PooledOpenTimeout exception: The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. This error could be because they are truly using all the pool slots. It could also be that their application is "leaking" connections (not properly closing/disposing connection objects or calling thread abort, which results in an orphaned connection object) and hitting max connections.

Other types of failures may occur due to connection errors like TCP remote host refused the connection. These types of failures can be hidden because retries during the timeout effectively hide the exceptions until the timeout error is thrown. These failures comprise a majority of the support cases that come in for the timeout error. The aspect that makes these painful is that SqlClient isn't capturing and surfacing the inner exception from the connection failure. It takes a memory dump at just the right time to get those details. If it could include the last connection exception as an inner exception on the PooledOpenTimeout exception, it would make connectivity troubleshooting significantly easier in these scenarios.

Describe the solution you'd like

During connection creation in a connection pool, capture the last connection exception (if a physical connection attempt was made) and surface that as the inner exception on PooledOpenTimeout if timeout occurs before a successful connection is made.

Alternatively, something like paulmedynski proposed below:

It might make sense for connection open retries to capture a list of all of the transient failures, and if the open ultimately fails (for a permanent error or timeout), provide the list of transient errors. A sort of ledger of what happened behind the Open() call to help diagnose failures.

Activity

  1. paulmedynski commented on Aug 8, 2025

    @paulmedynski
    Contributor

    It might make sense for connection open retries to capture a list of all of the transient failures, and if the open ultimately fails (for a permanent error or timeout), provide the list of transient errors. A sort of ledger of what happened behind the Open() call to help diagnose failures.

  2. moved this from To triage to Backlog in SqlClient Boardon Oct 28, 2025
  3. added
    Approved
    on Nov 21, 2025
  4. moved this from Backlog to In progress in SqlClient Boardon Aug 24, 2026
  5. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  6. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Feature
    Environment Not applicable (feature request)
    Area Area\Connection Pooling
    Duplicates None found (closely related open issues on pool timeout diagnostics: #4642, #4582, #4548, #2152, #1887, #2192 — none are exact duplicates)
    Regression Not indicated

    Analysis

    This is a feature request to improve diagnosability when a connection pool request fails (e.g. PooledOpenTimeout) by surfacing the last underlying connection exception (or a ledger of transient failures) as an inner exception, rather than only the generic timeout message. This affects DbConnectionPool/ChannelDbConnectionPool and connection-open retry logic. The issue is already labeled Approved and has an open linked pull request, #4590 ("Improve connection pool failure diagnostics"), which appears to implement this proposal. Severity: P2 (diagnostics/usability improvement, not a functional defect).

    Next Steps

    • Since implementation work is already underway in Improve connection pool failure diagnostics #4590, recommend reviewing and merging that PR rather than starting new work from scratch.
    • Maintainers should verify Improve connection pool failure diagnostics #4590 covers both the "pool exhaustion timeout" and "underlying connection failure" scenarios described in the issue, and that it captures the last transient exception (per paulmedynski's suggestion) rather than only the most recent one.
    • Confirm test coverage exists in ManualTests/FunctionalTests for the new inner-exception behavior on both ChannelDbConnectionPool and WaitHandleDbConnectionPool paths, and for both sync and async open paths.

    Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.

    Generated by SqlClient Issue Auto-Triage for #3545 · copilot · auto · 54.2 AIC · ⌖ 13 AIC · ⊞ 11.9K · ◷

  7. added this to the 8.1.0-preview1 milestone on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Approved

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions