Repository navigation
Enable overall connect timeout for pool waits by default - #5030
Conversation
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]>
There was a problem hiding this comment.
🔵 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
UseOverallConnectTimeoutForPoolWaittotrue, 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
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]>
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
benrr101
left a comment
There was a problem hiding this comment.
The meat and potatoes of the change seem simple enough :)
* 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]>
Description
Pool waits and login can receive separate
Connect Timeoutbudgets, allowing connection opening to exceed the caller's configured budget. EnableSwitch.Microsoft.Data.SqlClient.UseOverallConnectTimeoutForPoolWaitby 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
falseretains the compatibility behavior. No public API signatures change, andConnect Timeout=0remains 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 Timeoutbudget by default. SetSwitch.Microsoft.Data.SqlClient.UseOverallConnectTimeoutForPoolWait=falsebefore 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:
Result: passed, 116 tests.
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_ShouldRespectOrderOfRequesttest, 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.
Guidelines
Please review the contribution guidelines before submitting a pull request: