Repository navigation
test(integration): stop one failed SQL Server connect from failing every test - #805
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #805 +/- ##
==========================================
+ Coverage 95.75% 95.82% +0.07%
==========================================
Files 270 270
Lines 10475 10475
Branches 953 953
==========================================
+ Hits 10030 10038 +8
+ Misses 241 232 -9
- Partials 204 205 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ery test SqlClient's connection pool blocking period cached a single failed connect to the SQL Server container and rethrew it for every CREATE DATABASE on the shared master connection string, failing 96 net10.0 tests at once. Disable the blocking period for the test connection strings, retry failed connects with backoff, stop retrying once the server has proven unreachable, and add the container output to the failure message.
samtrion
force-pushed
the
fix/sqlserver-connection-blocking
branch
from
September 27, 2026 08:30
03ad4cf to
b2ecf63
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A single failed connect to the SQL Server test container failed 96 net10.0 integration tests at once in run 36300167080 (PR #799, an unrelated change). The cause is SqlClient's connection pool blocking period, which turned one failure into 96. This PR stops that amplification, retries failed connects, and adds the container output to the failure message so the next failure shows its cause.
Root cause (with evidence)
From the log of job
108566282533(attempt 1):failed: 96, all on net10.0 and allInvalidOperationException: Failed to create SQL Server test database .... net8.0 and net9.0 passed. The log shows 192 matching lines because each failure prints its message twice.masterconnection string, so they all share one pool. According to SqlConnectionStringBuilder.PoolBlockingPeriod, after a failed open "subsequent connection attempts will fail for the next five seconds ... up to a maximum of one minute". The defaultAutodisables this only for Azure SQL endpoints, so it applies to127.0.0.1.SocketException: Successcomes from managed SNI (SniTcpHandle.Connect).Socket.Selectreturned, but the socket was not connected andSO_ERRORwas 0. SqlClient does not treat this error 35 as transient (dotnet/SqlClient#4665), so nothing retried it.[SqlServerContainerFixture] ... crashed during startupline appears, so the container started normally and the test(integration): survive intermittent SQL Server 2025 startup crashes #796 startup retry did not apply. Passing tests are not printed, so the log cannot show whether the container was still alive after the failed connect (a crash during the run, as in [2025] Intermittent sqlpal crash on startup , ubuntu-24.04 only (~1.7% of starts, ~8.3% under concurrency) microsoft/mssql-docker#974). That state was not captured. This PR captures it from now on.Local reproduction with Microsoft.Data.SqlClient 7.1.0 (3 pooled opens against a closed port,
Connect Timeout=3):Changes
SqlServerContainerFixture.ConnectionStringappendsPool Blocking Period=NeverBlock. The per-test database connection strings are derived from it, so they get it as well.SqlServerDatabaseServiceFixtureretries a failedOpenAsyncup to 5 times with 1 s to 4 s backoff. The existing error 1807 retry stays the same, and both share the same attempt budget.GetLogsAsync). That shows whether SQL Server crashed or the problem was on the network side.Test evidence
dotnet build Pulse.slnx -c Release: 0 warnings, 0 errors. CSharpier formatted.Run Testson 03ad4cf, 3 runs: 9285/9285 passed each time (jobs 108570481884, 108573560556, 108577188666). None logged a startup crash or a database creation failure.