Repository navigation
SNI: Fix managed networking deadlocks on single-worker schedulers - #5147
Conversation
Run parallel SQL Browser requests on the default scheduler so a caller blocked in Task.WaitAny cannot starve its own request workers. Keep Strict TLS authentication completion independent of the caller's scheduler as well, preventing a follow-on deadlock after instance discovery. Add focused SSRP response/timeout and synchronous/asynchronous Strict TLS regressions. The original Windows CI dump confirms the SSRP scheduler cycle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The Windows named-instance/Strict-encryption pool regression still lacks a real SQL Server CI rerun validating discovery, TLS login, and pooled connection reuse under the single-worker scheduler.
No open issues 🎉
What changed in this PR
Fixes two managed SNI deadlocks when a connection opens on a single-worker scheduler: SQL Browser discovery workers and Strict TLS authentication continuations no longer depend on the blocked caller’s scheduler.
Changes:
- Runs parallel SQL Browser requests explicitly on
TaskScheduler.Default. - Prevents scheduler capture during TLS authentication with
ConfigureAwait(false). - Adds SQL Browser response/timeout tests and separate synchronous/asynchronous Strict TLS scheduler regressions.
Public APIs, pooling behavior, timeouts, and quarantine status remain unchanged. The real SQL Server named-instance CI rerun remains pending.
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/TlsHandshakeTimeoutTests.cs | Adds sync and async Strict TLS single-worker scheduler regressions. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/ManagedSni/SsrpClientTests.cs | Adds SQL Browser response and silent-peer timeout scheduler tests. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SsrpClient.netcore.cs | Schedules parallel discovery workers independently of the caller. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniHandle.netcore.cs | Avoids scheduler capture in the TLS authentication helper. |
Review effort: Balanced
Isolate scheduler-sensitive SSRP tests from unrelated blocking collections, match DateTime conversion errors using runtime en-US formatting, and preserve platform exclusions in flaky-test runs. Document the trait-based platform filtering contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5147 +/- ##
==========================================
+ Coverage 68.99% 70.51% +1.51%
==========================================
Files 314 315 +1
Lines 45857 70161 +24304
==========================================
+ Hits 31638 49471 +17833
- Misses 14219 20690 +6471
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:
|
|
What a find ! I have left a curiosity comment, please resolve after providing the response. Do not wait for me |
) (#5148) * SNI: Fix managed networking deadlocks on single-worker schedulers Run parallel SQL Browser requests on the default scheduler so a caller blocked in Task.WaitAny cannot starve its own request workers. Keep Strict TLS authentication completion independent of the caller's scheduler as well, preventing a follow-on deadlock after instance discovery. Add focused SSRP response/timeout and synchronous/asynchronous Strict TLS regressions. The original Windows CI dump confirms the SSRP scheduler cycle. * Fix CI test isolation, culture assertions, and quarantine filters Isolate scheduler-sensitive SSRP tests from unrelated blocking collections, match DateTime conversion errors using runtime en-US formatting, and preserve platform exclusions in flaky-test runs. Document the trait-based platform filtering contract. --------- Co-authored-by: Paul Medynski <31868385+paulmedynski@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Description
Fix two managed SNI deadlocks when opening a connection on a single-worker scheduler:
TaskScheduler.Default. The original CI dump confirms the caller was waiting for a request queued on its own blocked scheduler.ConfigureAwait(false). A separate regression reproduces this deadlock before the fix.Add SSRP response/timeout and sync/async TLS regressions. No public API, pooling, or timeout behavior changes.
Also correct CI quarantine filters across the shared test templates to use
category=flaky&category!=failing. Tests carrying both traits are now excluded from quarantine runs. This matters because XUnitExtensions'[PlatformSpecific]attribute adds thefailingtrait when a test is ineligible for the current platform, even if the test is also markedflaky. Update the testing/pipeline guidance to document this filtering behavior.Issues
The regression added in #5119 (backported in #5130) exposed the pre-existing driver bug. Original hang: MDS Main CI 195012.
Testing
$dllis the built Release/net10.0 unit-test assembly:eng/pipelines/scripts/tests/Pipeline-Platforms.Tests.ps1checks all three shared test templates (run-all-tests-step.yml,build-and-run-tests-netcore-step.yml, andbuild-and-run-tests-netfx-step.yml). It asserts that quarantine filters exist and that every matchedcategory=flakyfilter also includescategory!=failing. These assertions were inspected, not executed, as part of this description-only update.Full MDS Main CI run 195040 is queued against this PR's commit to validate the original test. Real-SQL validation remains pending; failed Strict-TLS mock login attempts are not counted as passes.
Guidelines
Please review the contribution guidelines before submitting a pull request: