Repository navigation
Synchronize virtual timer registration in concurrent pool timeout test - #5072
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 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
flakyand addprobationmetadata 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 Report✅ All modified and coverable lines are covered by tests. 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
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:
|
|
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
|
🤖 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.CreateTimerafter 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.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; replacingcategory=flakywithcategory!=failing&category!=flaky&category!=interactiveselects none. Executing withcategory=flaky&category=probationpassed one case per framework, zero skipped.git diff --checkpassed.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:
Contributing
Code of Conduct
Best Practices
Coding Style
Review Process
Tests added or updated
Public API changes documented (none; test-only repair)
Verified against customer repro (not applicable; controlled harness interleaving)
Ensure no breaking changes introduced