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

Will r2d2 create more connections than max_size when using builder()? #111

Closed
RKochenderfer opened this issue Sep 15, 2020 · 3 comments
Closed

Comments

@RKochenderfer
Copy link

My question is the title. The database I'm using has a very small number of connections allowed and I would like to make sure that the active connections does not exceed 4.

 let tmm10_pool = r2d2::Pool::builder()
            .max_size(4)
            .build(ODBCConnectionManager::new(&config.tmm_conn_string))?;

Will the code above ever allow a 5th connection to be created?

@sfackler
Copy link
Owner

The maximum size is the maximum number of connections the pool will maintain concurrently.

@RKochenderfer
Copy link
Author

So just to clarify for myself as I'm relatively inexperienced with connection pooling, if there are currently 4 connections being used and a 5th one needs to be made, will r2d2 make the 5th connection wait till another connection is dropped or will it make a 5th connection that isn't maintained by the pool?

@sfackler
Copy link
Owner

If the number of active connections is at the max_size, the pool will not make more connections.

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

No branches or pull requests

2 participants