Skip to content

Conversation

cheenamalhotra
Copy link
Member

Ports #3632 to release/6.0

@Copilot Copilot AI review requested due to automatic review settings October 3, 2025 19:37
@cheenamalhotra cheenamalhotra added this to the 6.0.3 milestone Oct 3, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a concurrency issue in the connection pool by introducing a new SemaphoreHolder class that properly manages semaphore acquisition and release using the disposable pattern. The fix ensures that semaphores are automatically released even when exceptions occur, preventing potential deadlocks in connection pool operations.

Key Changes

  • Introduces a new SemaphoreHolder class that implements IDisposable for automatic semaphore cleanup
  • Refactors semaphore usage in TryGetConnection and PoolCreateRequest methods to use the new pattern
  • Adds comprehensive connection pool stress tests to validate concurrent behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ConnectionPoolStressTest.cs New test file with comprehensive stress testing for connection pool concurrency scenarios
Microsoft.Data.SqlClient.ManualTesting.Tests.csproj Includes the new stress test file in the test project
DbConnectionPool.cs Implements the SemaphoreHolder class and refactors semaphore management to prevent concurrency issues

Copy link

codecov bot commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.82%. Comparing base (90bc83c) to head (93d7455).
⚠️ Report is 6 commits behind head on release/6.0.

Files with missing lines Patch % Lines
...rc/Microsoft/Data/ProviderBase/DbConnectionPool.cs 76.92% 3 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/6.0    #3654      +/-   ##
===============================================
+ Coverage        72.73%   75.82%   +3.08%     
===============================================
  Files              285      244      -41     
  Lines            59162    40211   -18951     
===============================================
- Hits             43034    30489   -12545     
+ Misses           16128     9722    -6406     
Flag Coverage Δ
addons 92.58% <ø> (ø)
netcore 75.69% <76.92%> (+0.16%) ⬆️
netfx ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@paulmedynski paulmedynski self-assigned this Oct 6, 2025
paulmedynski
paulmedynski previously approved these changes Oct 6, 2025
mdaigle
mdaigle previously approved these changes Oct 6, 2025
Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test code is mostly unused, please either remove it or operationalize it.
Take a look at the placement of the PreapreConstrainedRegions call in theDbConnectionPool class.

Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests need a lot of work before I'd approve of them normally. But I'm in a bind because this work has already been accepted on main, and the fix is important enough. I'd prefer it if you didn't submit this test file as part of this PR and back out the file in main. But considering you want it released asap since it's not really harming anything to add more incomplete code to the mountain of incomplete code in our test folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants