Connection pooling

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bjans
Posts: 4
Joined: Tue 25 Mar 2014 15:42

Connection pooling

Post by bjans » Fri 22 Aug 2014 09:45

I'm trying to set up connection pooling for my application but I'm not sure how to do it the right way.

My app is a web server that handles requests in threads. Eacht thread has its own connection that shoold be pooled. The DB coe looks like this:

Code: Select all

begin
  FDBCon := TMSConnection.Create(nil);
  try
    FDBCon.Server := FServer;
    FDBCon.Database := FDatabase;
    FDBCon.Username := FUser;
    FDBCon.Password := FPassword;
    FDBCon.Pooling := True;
    FDBCon.PoolingOptions.ConnectionLifetime := 60000;

    // create query and do stuff qith query / FDBCon

  finally
    FDBCon.Free;
  end;
end;
This works, but when the application terminates I get an exception with this call stack:

Code: Select all

OLEDBAccess.TOLEDBConnection.Disconnect
CRConnectionPool.TCRLocalConnectionPool.InternalFreeConnection($40FA640,False)
CRConnectionPool.TCRLocalConnectionPool.Clear
CRConnectionPool.TCRLocalConnectionPool.Destroy
System.TObject.Free
MemUtils.TDAObjectList.Notify($3D02DE0,lnDeleted)
System.Classes.TList.SetCount(0)
System.Classes.TList.Clear
CRConnectionPool.TCRConnectionPoolManager.InternalClear
CRConnectionPool.TCRConnectionPoolManager.Destroy
System.TObject.Free
MSConnectionPool.Finalization
I think the DBConnections that I freed earlier are still in the pool and destroyed again. If I don't free the FDBCon in the threads I don't get the exception on termination but then I have a memory leak for each TMSConnection.

How should I implement the lifecycle for a TMSConnection in a pooled situation?

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Connection pooling

Post by azyk » Tue 26 Aug 2014 11:48

We couldn't reproduce the problem. Please try to compose a small sample to demonstrate the problem and send it to andreyz*devart*com.

bjans
Posts: 4
Joined: Tue 25 Mar 2014 15:42

Re: Connection pooling

Post by bjans » Wed 27 Aug 2014 08:47

I emailed you a sample application. Could you reproduce the problem?

bjans
Posts: 4
Joined: Tue 25 Mar 2014 15:42

Re: Connection pooling

Post by bjans » Fri 29 Aug 2014 06:46

Hello...? Anybody there?

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Connection pooling

Post by azyk » Tue 02 Sep 2014 08:19

We received your test sample. We will investigate this behavior and inform you about the results.

bjans
Posts: 4
Joined: Tue 25 Mar 2014 15:42

Re: Connection pooling

Post by bjans » Wed 17 Sep 2014 08:32

Do you have any results already?

Post Reply