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

Pooling clears current active connections [DNET607] #569

Closed
firebird-automations opened this issue May 20, 2015 · 3 comments
Closed

Pooling clears current active connections [DNET607] #569

firebird-automations opened this issue May 20, 2015 · 3 comments

Comments

@firebird-automations
Copy link

Submitted by: @k3ldar

The following method within FbConnectionPoolManager.cs

public void CleanupPool()
{
lock (_syncRoot)
{
CheckDisposedImpl();
var now = DateTimeOffset.UtcNow;
var available = _available.ToArray();
var keep = available.Where(x => IsAlive(_connectionString.ConnectionLifeTime, x.Created, now)).ToArray();

	var keepCount = keep\.Count\(\);

	if \(keepCount < \_connectionString\.MinPoolSize\)
		keep = available\.Except\(keep\)\.Take\(\_connectionString\.MinPoolSize \- keepCount\)\.ToArray\(\);

	var release = available\.Except\(keep\)\.ToArray\(\);
	release\.AsParallel\(\)\.ForAll\(x =\> x\.Dispose\(\)\);
	\_available = new Queue<Item\>\(keep\);
	\}
\}

}

The line keep = available.Except(keep).Take(_connectionString.MinPoolSize - keepCount).ToArray(); will always clear existing connections when the number of connections is less than the Minimum Pool Size.

By removing the following lines, all works as expected:

	var keepCount = keep\.Count\(\);

	if \(keepCount < \_connectionString\.MinPoolSize\)
		keep = available\.Except\(keep\)\.Take\(\_connectionString\.MinPoolSize \- keepCount\)\.ToArray\(\);

Also the Take(_connectionString.MinPoolSize - keepCount) only takes account of the min pool size and not the maximum, so "other" connections above min pool size could also be lost at this point

The following is my connection string:

User=USERNAME;Password=password;Database=DBName.fdb;DataSource=127.0.0.1;Dialect=3;MinPoolSize=20;MaxPoolSize=150;Pooling=True;Connection lifetime=0;Packet Size=8192;CharSet=UTF8

Commits: 5456044

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: vNext [ 10704 ]

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

No branches or pull requests

2 participants