Skip to content

Enable overall connect timeout for pool waits by default - #5030

Merged
mdaigle merged 2 commits into
mainfrom
dev/mdaigle/pool-wait-timeout-default
Nov 12, 2026
Merged

mdaigle merged 2 commits into
mainfrom
dev/mdaigle/pool-wait-timeout-default

Conversation

@mdaigle

@mdaigle mdaigle commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Description

Pool waits and login can receive separate Connect Timeout budgets, allowing connection opening to exceed the caller's configured budget. Enable Switch.Microsoft.Data.SqlClient.UseOverallConnectTimeoutForPoolWait by default so time consumed during pool acquisition reduces the budget available for login.

This intentionally changes default behavior: applications may time out sooner under pool contention. Explicitly setting the existing switch to false retains the compatibility behavior. No public API signatures change, and Connect Timeout=0 remains infinite.

Update migration documentation and switch guidance, and extend regression coverage for unset, enabled, and disabled settings, synchronous and asynchronous acquisition, both pool implementations, and login budget selection. The separate in-open round-trip work tracked by #4582 remains out of scope.

Suggested release note: Pool waits now count against the connection's overall Connect Timeout budget by default. Set Switch.Microsoft.Data.SqlClient.UseOverallConnectTimeoutForPoolWait=false before using SqlClient to restore the previous behavior.

Issues

Fixes #4642

Related: #4270 and #4582.

Testing

Regression assertions were confirmed failing before changing the default. Coverage includes remaining-budget propagation, expired/infinite wait budgets, and the explicit compatibility opt-out. Existing simulated-server tests also exercise public synchronous and asynchronous connection opening.

The following exact test commands were run from the repository root:

dotnet test src\Microsoft.Data.SqlClient\tests\UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj --framework net10.0 --no-restore --filter "FullyQualifiedName~LocalAppContextSwitchesTest|FullyQualifiedName~SqlConnectionInternalTimeoutTests|FullyQualifiedName~WaitHandleDbConnectionPoolBudgetTest|FullyQualifiedName~ChannelDbConnectionPoolTest|FullyQualifiedName~SimulatedServerTests.ConnectionTests.ConnectionTest|FullyQualifiedName~SimulatedServerTests.ConnectionTests.MultiSubnetFailover_Default_CachedFailoverPartner_OpenSucceeds" --blame-hang-timeout 10m --logger "console;verbosity=normal"

Result: passed, 116 tests.

dotnet test src\Microsoft.Data.SqlClient\tests\UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj --framework net462 --no-build --no-restore --filter "FullyQualifiedName~LocalAppContextSwitchesTest|FullyQualifiedName~SqlConnectionInternalTimeoutTests|FullyQualifiedName~WaitHandleDbConnectionPoolBudgetTest|FullyQualifiedName~ChannelDbConnectionPoolTest|FullyQualifiedName~SimulatedServerTests.ConnectionTests.ConnectionTest|FullyQualifiedName~SimulatedServerTests.ConnectionTests.MultiSubnetFailover_Default_CachedFailoverPartner_OpenSucceeds" --blame-hang-timeout 10m --logger "console;verbosity=normal"

Result: passed, 115 tests. An earlier run of the same selection, with a build and concurrent .NET 10 validation, had one failure in the unchanged GetConnectionMaxPoolSize_ShouldRespectOrderOfRequest test, marked with active issue #3730. All new timeout cases passed in that run; the full selection passed on the standalone rerun above.

Live SQL Server manual tests were not run. Validation used isolated pool tests and the in-process TDS server.

  • Tests added or updated
  • Public API changes documented (behavioral change documented; no signature changes)
  • Verified against customer repro (N/A: default-behavior feature request)
  • Ensure no breaking changes introduced (intentional default behavior change, with compatibility opt-out)

Guidelines

Please review the contribution guidelines before submitting a pull request:

Preserve the explicit false compatibility opt-out, document migration behavior, and cover remaining-budget propagation for both pool implementations and acquisition paths.

Co-authored-by: Copilot App <[email protected]>
@mdaigle
mdaigle requested a review from a team November 10, 2026 18:55
Copilot AI balanced review requested due to automatic review settings November 10, 2026 18:55
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 10, 2026
@mdaigle mdaigle added this to the 8.0.0 milestone Nov 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Source and diff inspection is complete, but required skill-reference and review-policy checks could not be completed because no trusted immutable source was established.

No open issues 🎉

What changed in this PR

Enables overall connection-timeout budgeting by default, so pool waits reduce the time available for login. This implements #4642 while preserving the explicit compatibility opt-out; the separate in-open round trips tracked by #4582 remain out of scope.

Changes:

  • Defaults UseOverallConnectTimeoutForPoolWait to true, without changing public API signatures.
  • Extends regression coverage for default and explicit switch settings, synchronous and asynchronous pool acquisition, and login-budget selection.
  • Documents the behavioral change, compatibility opt-out, and unchanged infinite-timeout behavior.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft/​Data/​SqlClient/​SqlConnectionInternalTimeoutTests.cs Tests remaining login budgets and fresh budgets with the opt-out.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft/​Data/​SqlClient/​LocalAppContextSwitchesTest.cs Updates the expected switch default to enabled.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​ConnectionPool/​WaitHandleDbConnectionPoolBudgetTest.cs Expands budget propagation, expiration, and compatibility tests.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​ConnectionPool/​ChannelDbConnectionPoolTest.cs Tests synchronous and asynchronous budget propagation across switch settings.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​LocalAppContextSwitches.cs Enables the default and clarifies switch documentation.
doc/​networking-defaults.md Adds migration guidance and the compatibility opt-out example.
.github/​instructions/​features.instructions.md Documents the switch default and pool-wait budget behavior.

Review effort: Balanced

@mdaigle mdaigle added the Hotfix 8.0.0 PRs that must be backported to release/8.0 label Nov 10, 2026
@mdaigle mdaigle modified the milestones: 8.0.0, 8.1.0-preview1 Nov 10, 2026
Give the warmup test its intended 15-second creation budget now that overall timeout enforcement honors the supplied timer. Preserve all application-attribution assertions.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Required supplemental review-reference checks could not be completed without a trusted immutable source, and current-head CI is still running.

No open issues 🎉

Review effort: Balanced

@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.18%. Comparing base (5aaa9ef) to head (9adecf6).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5030      +/-   ##
==========================================
- Coverage   74.02%   69.18%   -4.85%     
==========================================
  Files         313      314       +1     
  Lines       45726    69726   +24000     
==========================================
+ Hits        33848    48237   +14389     
- Misses      11878    21489    +9611     
Flag Coverage Δ
CI-SqlClient ?
sqlclient-pr 69.18% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@benrr101 benrr101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meat and potatoes of the change seem simple enough :)

@mdaigle
mdaigle merged commit 8527b16 into main Nov 12, 2026
39 checks passed
@mdaigle
mdaigle deleted the dev/mdaigle/pool-wait-timeout-default branch November 12, 2026 16:10
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Nov 12, 2026
mdaigle added a commit that referenced this pull request Nov 13, 2026
* Enable overall connect timeout for pool waits by default

Preserve the explicit false compatibility opt-out, document migration behavior, and cover remaining-budget propagation for both pool implementations and acquisition paths.



* Use milliseconds for background pool test timeout

Give the warmup test its intended 15-second creation budget now that overall timeout enforcement honors the supplied timer. Preserve all application-attribution assertions.



---------

Co-authored-by: Malcolm Daigle <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@mdaigle mdaigle mentioned this pull request Nov 16, 2026
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hotfix 8.0.0 PRs that must be backported to release/8.0

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Enable UseOverallConnectTimeoutForPoolWait by default in 8.0

5 participants