Repository navigation
SNI: Fix managed networking deadlocks on single-worker schedulers - #5147
paulmedynski wants to merge 2 commits into
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>
| -p:PackageVersionSqlClient=${{ parameters.packageVersion }} | ||
| -p:PackageVersionSqlServer=${{ parameters.sqlServerPackageVersion }} | ||
| -p:TestFilters="category=flaky" | ||
| -p:TestFilters="category=flaky&category!=failing" |
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:
|
| -p:PackageVersionSqlClient=${{ parameters.packageVersion }} | ||
| -p:PackageVersionSqlServer=${{ parameters.sqlServerPackageVersion }} | ||
| -p:TestFilters="category=flaky" | ||
| -p:TestFilters="category=flaky&category!=failing" |
There was a problem hiding this comment.
I think the intention of the change is to avoid running failing tests in the Flaky tests step. Failing would always fail so not excluding them in the first place with Flaky tests was a wrong choice, is that correct ?
There was a problem hiding this comment.
Two unexpected things converged here:
- We, as test authors, never intended to have the "flaky" and "failing" traits applied to a test at the same time - it's one or the other, so the filters never accounted for that.
- The XUnitExtensions
[PlatformSpecific]attribute injects a "failing" trait onto tests whose required platform doesn't match the runtime. Yowzers!
The surprising [PlatformSpecific] implementation coufounded our original assumption, and now we must explicitly exclude "failing" everywhere, because it no longer means "tests we explicitly marked as failing". It has been expanded to include "tests that shouldn't run on this platform". Perhaps upgrading to xUnit3 will help with situations like this since it has a richer filtering engine.
|
What a find ! I have left a curiosity comment, please resolve after providing the response. Do not wait for me |

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, timeout, or quarantine changes.
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: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: