Skip to content

Fix shared-transaction test worker starvation - #5094

Merged
mdaigle merged 1 commit into
mainfrom
dev/mdaigle/quarantined-flaky-repair
Nov 18, 2026
Merged

mdaigle merged 1 commit into
mainfrom
dev/mdaigle/quarantined-flaky-repair

Conversation

@mdaigle

@mdaigle mdaigle commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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

Description

Repair Microsoft.Data.SqlClient.UnitTests.ConnectionPool.WaitHandleDbConnectionPoolTransactionTest.TwoThreads_SharedTransaction_AccessSameTransactedEntry (Fact; no arguments).

Demonstrated mechanism: the caller synchronously waits for two Task.Run workers, and the consumer synchronously waits for the producer. With no spare pool worker, Task.WaitAll can inline the consumer ahead of the queued producer, causing the existing ten-second handoff assertion to fail. An isolated child process restricted to one worker reproduced the recorded assertion on both net462 and net10.0; this is a controlled starvation scenario, not a reconstruction of the original agent's exact load.

Use two dedicated LongRunning tasks on TaskScheduler.Default, preserving transaction flow, handoff order, timeout and connection-identity assertions. Remove the unused event and replace the obsolete “never reproduces locally” comment with behavior documentation. No production, API or pipeline changes.

Retain [Trait("category", "flaky")] and add [Trait("category", "probation")]. Probation starts separately on each upstream branch only when its repair and both traits actually merge there. This unmerged proposal starts no probation interval; later category transitions belong to the independent reviewer.

Release applicability: the same defective method exists on release/7.1 and release/8.0, and the complete one-file repair/category diff applies cleanly to both. The existing Hotfix 7.1.3 and Hotfix 8.0.0 labels are applied. The method is absent from release/6.1 and release/7.0. Release-branch binaries, including 7.1's net8.0/net9.0 targets, have not been executed.

Issues

The existing method-level quarantine records this same timeout; no separate issue is closed.

Testing

dotnet test src\Microsoft.Data.SqlClient\tests\UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj --no-restore --filter 'FullyQualifiedName~WaitHandleDbConnectionPoolTransactionTest' -v:q
dotnet test src\Microsoft.Data.SqlClient\tests\UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj --no-restore -c Release --filter 'FullyQualifiedName~WaitHandleDbConnectionPoolTransactionTest' -v:q

Both commands passed 27 net462 + 27 net10.0, zero failures/skips, including neighboring sync/async transaction coverage. The identical isolated single-worker control failed before this repair and passed afterward on both frameworks; repaired Release controls also passed net462 x86/x64 and net10.0 x64. No process-wide worker limits are changed by the committed test.

Actual discovery and Release execution with FullyQualifiedName~WaitHandleDbConnectionPoolTransactionTest&category=flaky selected/passed exactly this one Fact per framework. The ordinary category!=failing&category!=flaky&category!=interactive conjunction excluded it and selected/passed all 26 siblings per framework. Both used dotnet test with --no-build --no-restore and the same project above; discovery additionally used --list-tests.

CI: scoped build 192845, on the repair SHA with Release/Project/Set 1, verified this Fact in quarantine and all 27 transaction-class cases on Windows SQL25 x86/net462 (native-SNI configuration). PR build 192846, on merge d68a1fcc80d4f712aa7a2b83a58d132eb6a71d44, verified all 26 ordinary transaction siblings on Linux net10.0 Debug/Project and excluded this Fact. These tests use mock connections, not physical SQL/SNI connectivity.

CI limits: scoped Windows net10.0 tests did not execute because PowerShell module restoration received feed HTTP 403 (missing Reader permission). Latest PR build 192870, on the same merge SHA, again failed that prerequisite in two Windows managed-SNI manual jobs; it supplies no additional affected-case pass. The focused sqlclient-ci-unit alternative cannot load on the repair SHA because its configured /eng/pipelines/ci/unit/sqlclient-ci-unit-pipeline.yml is absent. Ubuntu24 SQL25/net10.0 managed-SNI quarantine reported 34 passes with no skips, but its XML result-publication failure persisted after an unchanged retry and also occurs on unrepaired main. No individual Linux quarantine pass is claimed. Linked execution records and failure controls are in the single evidence comment.

Guidelines

Please review the contribution guidelines before submitting a pull request:

Use dedicated workers for the synchronous transaction handoff so the waiting consumer cannot occupy the worker needed by the producer. Preserve flaky quarantine and add probation.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 14:20
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 17, 2026
@mdaigle mdaigle added Hotfix 7.1.3 Hotfix 8.0.0 PRs that must be backported to release/8.0 labels Nov 17, 2026
@mdaigle mdaigle added this to the 8.1.0-preview1 milestone Nov 17, 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

No active review issues are reported for this test-only change that removes shared-transaction workers’ dependence on thread-pool availability.

No open issues 🎉

What changed in this PR

This test-only repair removes thread-pool availability as a dependency of the shared-transaction connection-pool test. Production code, public APIs, and pipelines are unchanged.

Changes:

  • Uses two LongRunning tasks on TaskScheduler.Default, preserving transaction handling, handoff timeout, and connection-identity assertions.
  • Removes an unused synchronization event and replaces the obsolete failure commentary with behavior-focused documentation.
  • Retains flaky quarantine and adds probation tracking.
File Description
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​ConnectionPool/​WaitHandleDbConnectionPoolTransactionTest.cs Isolates workers from thread-pool starvation and updates test documentation and probation metadata.

Review effort: Balanced

@mdaigle

mdaigle commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Execution mappings below use stage/phase/job attempts; each mapped task is attempt 1. Times are UTC on 2026-11-17.

Record Stage / phase / job; attempts UTC
Quarantine 192845 / 3730839 / 103984 Win25_Sql25_x86 / net462_AnyCPU_1 / __default; 2/2/2 14:47:27.900-14:47:28.007
Ordinary async control 192846 / 3730792 / 101607 test_linux_net10 / test_linux_net10_sqlclient_unit / __default; 1/1/1 14:39:25.573-14:39:25.603
Linux execution log 253 / publisher log 258 Ubuntu24_Sql25 / net10_0_AnyCPU_ManagedSNI_1 / __default; 2/2/2 Execution 15:18:20.757-15:19:07.487; publisher 15:32:48.780
Unrepaired publisher control 192629 / log 3445 Same Linux phase; 1/1/1; source 0304c75eb048c6a309cccfc50629b38aca82d53b 01:32:54.752

Mapped prerequisite logs: scoped build / 150.

Additional prerequisite record Windows net10.0 managed-SNI job; stage/phase/job attempts UTC
192870 / log 304 sqlclient_manual_localhost_managedSni_123_windows_net10; 1/1/1 15:54:07.634-15:54:19.979
192870 / log 283 sqlclient_manual_localdb_managedSni_123_windows_net10; 1/1/1 15:54:06.988-15:54:12.659

@mdaigle
mdaigle marked this pull request as ready for review November 17, 2026 15:36
@mdaigle
mdaigle requested a review from a team as a code owner November 17, 2026 15:36
@paulmedynski paulmedynski added Hotfix 7.1.3 PRs targeting main that should be backported to release/7.1 for 7.1.3. and removed Hotfix 7.1.2 labels Nov 17, 2026
@saurabh500

Copy link
Copy Markdown
Collaborator

Very cool analysis

@mdaigle
mdaigle enabled auto-merge (squash) November 18, 2026 21:35
@mdaigle
mdaigle merged commit f078a5e into main Nov 18, 2026
66 of 67 checks passed
@mdaigle
mdaigle deleted the dev/mdaigle/quarantined-flaky-repair branch November 18, 2026 22:12
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.98%. Comparing base (17bef7b) to head (786dd8e).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5094      +/-   ##
==========================================
+ Coverage   68.99%   69.98%   +0.99%     
==========================================
  Files         314      315       +1     
  Lines       45857    69808   +23951     
==========================================
+ Hits        31638    48855   +17217     
- Misses      14219    20953    +6734     
Flag Coverage Δ
CI-SqlClient ?
sqlclient-pr 69.98% <ø> (?)

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 added a commit that referenced this pull request Nov 18, 2026
Use dedicated workers for the synchronous transaction handoff so the waiting consumer cannot occupy the worker needed by the producer. Preserve flaky quarantine and add probation.

Co-authored-by: Malcolm Daigle <[email protected]>
Co-authored-by: Copilot App <[email protected]>
mdaigle added a commit that referenced this pull request Nov 19, 2026
Use dedicated workers for the synchronous transaction handoff so the waiting consumer cannot occupy the worker needed by the producer. Preserve flaky quarantine and add probation.

Co-authored-by: Malcolm Daigle <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hotfix 7.1.3 PRs targeting main that should be backported to release/7.1 for 7.1.3. Hotfix 8.0.0 PRs that must be backported to release/8.0

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants