Pooling clears current active connections
-----------------------------------------

                 Key: DNET-607
                 URL: http://tracker.firebirdsql.org/browse/DNET-607
             Project: .NET Data provider
          Issue Type: Bug
          Components: ADO.NET Provider
    Affects Versions: 4.6.2.0
         Environment: Windows 8
Visual Studio Pro 2013
Firebird 2.5.2
            Reporter: Simon Carter
            Assignee: Jiri Cincura


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

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to