Dev/mdaigle/pool rate limit#4376
Draft
mdaigle wants to merge 19 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds infrastructure for connection-pool rate limiting and aligns both pool implementations on a shared “blocking period” error-state mechanism (fast-fail after connection-creation failures with exponential backoff), with accompanying unit tests and a draft spec.
Changes:
- Introduces
BlockingPeriodErrorStateand integrates it into bothChannelDbConnectionPoolandWaitHandleDbConnectionPool. - Adds initial plumbing for connection-creation rate limiting in
ChannelDbConnectionPool(plusNoOpAcquiredLease). - Adds unit tests and a feature spec/diagram documenting intended behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/ChannelDbConnectionPoolTest.cs | Adds unit tests for blocking period behavior and rate-limit lease disposal scenarios. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs | Refactors blocking-period logic to use the shared BlockingPeriodErrorState and pool-group policy helper. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/NoOpAcquiredLease.cs | Adds a singleton no-op RateLimitLease used when no limiter is configured. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolGroup.cs | Centralizes blocking-period enablement policy in IsBlockingPeriodEnabled(). |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/ChannelDbConnectionPool.cs | Adds blocking-period error state support and rate-limit acquisition logic on connection creation. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/BlockingPeriodErrorState.cs | New shared implementation for cached error + exponential backoff + timer-based recovery. |
| src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj | Adds System.Threading.RateLimiting package reference. |
| specs/006-pool-rate-limiting/spec.md | Draft feature specification for rate limiting + blocking period semantics. |
| specs/006-pool-rate-limiting/diagrams.md | Mermaid diagrams comparing old vs new pool throttling approach. |
| Directory.Packages.props | Adds central package version entry for System.Threading.RateLimiting. |
Comment on lines
+1503
to
+1507
| var sw = Stopwatch.StartNew(); | ||
| var second = Assert.Throws<InvalidOperationException>(() => | ||
| pool.TryGetConnection(new SqlConnection(), taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out _)); | ||
| sw.Stop(); | ||
|
|
Contributor
Author
|
@copilot add a System.Threading.RateLimiting dependency in the manual tests project |
Co-authored-by: mdaigle <4722049+mdaigle@users.noreply.github.com>
Contributor
Added |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Provide a summary of the changes being introduced. Important topics to cover
include:
High quality descriptions will lead to a smoother review experience.
Issues
Link to any relevant issues, bugs, or discussions (e.g.,
Closes #123,Fixes issue #456).Testing
Describe the automated tests (unit, integration) you created or modified.
Provide justification for any gap in automated testing. List any manual testing
steps that were performed to ensure the changes work.
Guidelines
Please review the contribution guidelines before submitting a pull request: