Test | Connection pool transaction tests#3805
Conversation
…ransacted-pool-stress-tests
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive stress tests for connection pool transaction handling under high concurrency scenarios. The tests verify that the WaitHandleDbConnectionPool and TransactedConnectionPool correctly manage connections when multiple threads perform transactional operations concurrently. Additionally, the PR removes several transitive package references for vulnerable dependencies that are no longer needed.
Key Changes
- Added
WaitHandleDbConnectionPoolTransactionStressTest.cswith extensive transaction stress tests covering various concurrency patterns - Exposed internal properties in
WaitHandleDbConnectionPoolandTransactedConnectionPoolfor test observability - Removed explicit references to
System.Formats.Asn1,System.Text.Json, andSystem.Text.Encodings.Webpackages (transitive dependencies)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
WaitHandleDbConnectionPoolTransactionStressTest.cs |
New comprehensive test file with 1125 lines covering transaction stress scenarios including per-iteration transactions, per-thread transactions, shared transactions, pool saturation, nested transactions, mixed transacted/non-transacted operations, and edge cases |
WaitHandleDbConnectionPool.cs |
Changed MaxPoolSize and MinPoolSize from private to internal, and exposed TransactedConnectionPool property as internal for test observability |
TransactedConnectionPool.cs |
Changed TransactedConnectionList to internal and replaced private _transactedCxns dictionary with internal TransactedConnections property for test access |
Microsoft.Data.SqlClient.ExtUtilities.csproj |
Removed explicit reference to System.Formats.Asn1 package |
netcore/src/Microsoft.Data.SqlClient.csproj |
Removed explicit reference to System.Text.Json package |
netcore/ref/Microsoft.Data.SqlClient.csproj |
Removed explicit reference to System.Text.Json package |
AzureKeyVaultProvider.csproj |
Removed explicit reference to System.Text.Encodings.Web package |
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
....SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionStressTest.cs
Outdated
Show resolved
Hide resolved
…ss tests. Improve prompts.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3805 +/- ##
==========================================
- Coverage 73.22% 66.38% -6.85%
==========================================
Files 280 274 -6
Lines 43000 65782 +22782
==========================================
+ Hits 31486 43668 +12182
- Misses 11514 22114 +10600
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Tests/SqlClientTestGroup.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/IDbConnectionPool.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
paulmedynski
left a comment
There was a problem hiding this comment.
Looks great overall - It will be so nice to have a pool that is well documented, tested, and understood.
...osoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/TransactedConnectionPool.cs
Outdated
Show resolved
Hide resolved
...osoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/TransactedConnectionPool.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Outdated
Show resolved
Hide resolved
...osoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/TransactedConnectionPool.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
...t.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Tests/SqlClientTestGroup.cs
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
…daigle/transacted-pool-stress-tests
This pull request introduces several improvements and refactorings across prompt definitions and the SQL client connection pool implementation. The most notable changes include enhanced tool scoping for prompts, improved naming and file references, and a refactor of the transaction-aware connection pool for clarity and maintainability.
Prompt and Documentation Improvements:
toolsfield to prompt YAML frontmatter and updated documentation to recommend explicit tool scoping for each prompt, including a new section detailing tool selection best practices and syntax. This helps ensure prompts only access the tools they need, improving reliability and safety. [1] [2] [3]doc-comments→generate-doc-comments,test-minimize-overlap→refine-test-overlap) and updated skill and script references to use consistent, absolute paths. [1] [2] [3]Connection Pool Refactoring and Enhancements:
TransactedConnectionPoolthrough theIDbConnectionPoolinterface and relevant concrete classes, allowing better management of connections enlisted in transactions. [1] [2] [3] [4]TransactedConnectionPoolto useTransactedConnections(aDictionary<Transaction, TransactedConnectionList>) with improved naming, access modifiers, and thread safety in lock usage. TheTransactedConnectionListis nowinternalfor broader accessibility within the assembly. [1] [2] [3] F2ff1f1cL93R93, F2ff1f1cL122R122, [4] F2ff1f1cL181R181, F2ff1f1cL212R212, F2ff1f1cL237R237, F2ff1f1cL296R296, F2ff1f1cL318R318)TryGetConnectionmethod signature inIDbConnectionPoolto allow a nullableTaskCompletionSource, increasing flexibility in connection retrieval logic.Other Codebase Improvements:
MaxPoolSizeandMinPoolSizeasinternalinWaitHandleDbConnectionPoolfor improved testability or cross-class usage.CreationTimeoutproperty inDbConnectionPoolOptionsfor clearer documentation.Issues
#3356
Testing
Added comprehensive tests for WaitHandleDbConnectionPool's transacted connection flows. Extended stress tests to include transaction scenarios.