Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core pooling logic #2686

Merged
merged 28 commits into from
Jul 25, 2024
Merged

Core pooling logic #2686

merged 28 commits into from
Jul 25, 2024

Conversation

mdaigle
Copy link
Contributor

@mdaigle mdaigle commented Jul 18, 2024

This PR covers core pooling logic including SqlConnector creation, retrieval, return, and statistics. Integrates with rate limiter scaffolding added in #2667. Also covers small fixes for create, close, and dispose flows exposed by unit tests.

Not included in this PR are:

  • warmup
  • pruning
  • clearing the pool
  • data source disposal
  • connection lifetime evaluation
  • metrics and reporting
  • exception patterns in line with the rest of the driver

Copy link
Contributor

@edwardneal edwardneal left a comment

Choose a reason for hiding this comment

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

I think this matches our discussion about pooling (pending the missing parts you've already noted.) There are a few points of code formatting/indentation/resource strings, but nothing worth a specific comment until the PR's out of draft. I'm happy with the base methodology (besides one or two nits in review comments.)

@mdaigle mdaigle marked this pull request as ready for review July 19, 2024 21:57
@mdaigle mdaigle changed the title Pooling internals Core pooling logic Jul 19, 2024


[Fact]
public async Task MinPoolSize_equals_MaxPoolSize()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just going to suggest my philosophy of unit test organization - organizing them into Arrange, Act, Assert is a fairly standard practice that helps make it clear what's being tested.

}

[Fact]
public void MinPoolSize_bigger_than_MaxPoolSize_throws()
Copy link
Contributor

Choose a reason for hiding this comment

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

Also usually naming the tests like MethodName_OptionalCondition_Outcome is a bit more readable
Eg, for this one I'd rename it MinPoolSize_BiggerThanMaxPoolSize_Throws

src/Microsoft.Data.SqlClient/tests/UnitTests/PoolTests.cs Outdated Show resolved Hide resolved
};

// Start an async open which will not complete as the pool is exhausted.
var asyncOpenerTask = asyncOpener();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit confused on this one... Would this be more simply expressed using Task.Run?

src/Microsoft.Data.SqlClient/tests/UnitTests/PoolTests.cs Outdated Show resolved Hide resolved
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.

A few low-tier commends, but nothing that I'd hold up checkin in on. I think.

@mdaigle mdaigle merged commit a97e2f1 into dotnet:feat/sqlclientx Jul 25, 2024
11 checks passed
@mdaigle mdaigle deleted the pooling-internals branch July 25, 2024 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants