Skip to content

Synchronize virtual timer registration in concurrent pool timeout test - #5072

Merged
mdaigle merged 1 commit into
mainfrom
dev/mdaigle/sqlclient-flaky-repairs
Nov 16, 2026
Merged

mdaigle merged 1 commit into
mainfrom
dev/mdaigle/sqlclient-flaky-repairs

Conversation

@mdaigle

@mdaigle mdaigle commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🤖 This pull request was created by a fully automated workflow.

Description

Repair Microsoft.Data.SqlClient.UnitTests.ConnectionPool.ChannelDbConnectionPoolTest.ConcurrentCallers_ShouldTimeoutIndependently (Fact; no arguments).

Demonstrated mechanism: the test advances its shared fake clock immediately after scheduling two workers. If advancement falls between reading a caller's remaining budget and registering its relative cancellation timer, that timer is scheduled beyond the advanced clock. With no further advancement, the short caller can wait indefinitely. Advancing before the remaining-budget read instead yields an already-canceled source; these are different interleavings.

Wait asynchronously for both actual timer registrations before advancing time. A unit-only notifying fake clock signals after registration, not merely worker startup. Preserve the short-caller timeout assertion, longer-caller pending assertion and reuse of the exact held connection. Bound readiness and both completion waits, and shut down/clear the test pool during cleanup. No sleeps, exception suppression, production API, dependency, localization or pipeline changes.

Retain [Trait("category", "flaky")] and add [Trait("category", "probation")]. Probation starts only when a merge makes this repair and both markings effective upstream, never on proposal creation. The existing convention is unchanged.

Issues

#4476 quarantined this same test after a CI hang. The registration race is demonstrated locally; the historical hang dump has not been analyzed, so it is not claimed to establish the sole cause of that incident. No issue is closed.

Testing

A temporary controlled experiment paused TimeProvider.CreateTimer after the remaining-budget read. Advancing two virtual seconds before releasing registration left the one-second cancellation pending (failed on net462 and net10.0); registering first and then advancing canceled it (passed on both). This establishes the harness interleaving, not a production deadlock reproduction; the temporary diagnostic is not shipped.

dotnet test src\Microsoft.Data.SqlClient\tests\UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj --no-restore --filter "FullyQualifiedName~ConcurrentCallers_ShouldTimeoutIndependently|FullyQualifiedName~TimeoutTimerTest|FullyQualifiedName~GetConnectionMaxPoolSize_ShouldTimeoutAfterPeriod|FullyQualifiedName~GetConnectionAsyncMaxPoolSize_ShouldTimeoutAfterPeriod" -v:q --blame-hang-timeout 2m

Passed: 25 net462 / 25 net10.0, zero skipped, Debug and Release (add -c Release), including synchronous and asynchronous exhausted-pool timeout coverage. The repaired Fact itself is the synchronized regression.

With --no-build --no-restore --list-tests --filter "FullyQualifiedName~ConcurrentCallers_ShouldTimeoutIndependently&category=flaky", each framework selects the Fact; replacing category=flaky with category!=failing&category!=flaky&category!=interactive selects none. Executing with category=flaky&category=probation passed one case per framework, zero skipped. git diff --check passed.

CI: scoped build 192482, PR build 192483 and ready-triggered rerun 192497 completed successfully. Individual records confirm the affected quarantine Fact and 24 focused timeout controls passed on both Windows frameworks. Each ordinary PR unit run passed those 24 controls and excluded the Fact. Execution records and configuration mappings.

Limit: Linux quarantine output reports 34 passes and zero skips, but publisher log 111 rejected XML, and two authenticated MCP artifact downloads returned empty content. No individual affected-case pass is counted for Linux. No indefinite-stability or unskipped-full-suite claim.

Guidelines

Please review the contribution guidelines before submitting a pull request:

Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:11
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 16, 2026
@mdaigle mdaigle added this to the 8.1.0-preview1 milestone Nov 16, 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.

🟢 Approval recommended

There are no active review issues for the test-only change addressing the virtual-time registration race.

No open issues 🎉

What changed in this PR

This test-only PR addresses a virtual-time registration race in ConcurrentCallers_ShouldTimeoutIndependently, previously quarantined in #4476. It synchronizes clock advancement with cancellation-timer registration without changing production behavior.

Changes:

  • Add a notifying fake clock that signals after each timer is registered.
  • Wait for both registrations before advancing time, bound completion waits, and add pool cleanup while preserving timeout and exact-connection reuse assertions.
  • Retain flaky and add probation metadata without changing quarantine routing.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Utilities/​NotifyingTimeProvider.cs Adds a unit-test helper that reports completed timer registration.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​ConnectionPool/​ChannelDbConnectionPoolTest.cs Synchronizes virtual-time advancement, bounds waits, adds cleanup, and marks the repaired test for probation.

Review effort: Balanced

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.99%. Comparing base (17bef7b) to head (9ccc693).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5072      +/-   ##
==========================================
+ Coverage   68.99%   69.99%   +1.00%     
==========================================
  Files         314      314              
  Lines       45857    69767   +23910     
==========================================
+ Hits        31638    48835   +17197     
- Misses      14219    20932    +6713     
Flag Coverage Δ
CI-SqlClient ?
sqlclient-pr 69.99% <ø> (?)

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.

@mdaigle

mdaigle commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Execution map: 2026-11-16 UTC, Project references / AnyCPU. Mapped unit phase/job attempts are 1. Build 192497's final Windows net10 stage attempt is 2; only manual jobs were retried. That build uses merge commit a81bf96522e5b81a12604666529ea8ec28dbb649, whose Git tree was verified identical to the repair tree.

Build / run Configuration; stage / phase Provider record; UTC start
192482 / 3724965 Release, Windows native SNI; Win25_Sql25 / net462_AnyCPU_1 Quarantine case 103981; 17:37:12.407
192482 / 3724963 Release, Windows native SNI; Win25_Sql25 / net10_0_AnyCPU_NativeSNI_1 Quarantine case 104097; 17:37:41.670
192497 / 3725300 Debug, Windows platform-default SNI; test_windows_net462 / test_windows_net462_sqlclient_unit Ordinary run; 18:29:31.907
192497 / 3725285 Debug, Windows platform-default SNI; test_windows_net10 / test_windows_net10_sqlclient_unit Ordinary run; 18:28:07.847
192497 / 3725288 Debug, Linux managed SNI; test_linux_net10 / test_linux_net10_sqlclient_unit Ordinary run; 18:28:57.087

@mdaigle
mdaigle marked this pull request as ready for review November 16, 2026 18:08
@mdaigle
mdaigle requested a review from a team as a code owner November 16, 2026 18:08
@mdaigle
mdaigle merged commit 0304c75 into main Nov 16, 2026
54 of 55 checks passed
@mdaigle
mdaigle deleted the dev/mdaigle/sqlclient-flaky-repairs branch November 16, 2026 22:01
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants