There is a performance issue and potential bug related to TZDbcPooledConnection when disconnecting a connection. I would like to propose a small change that will help a lot.
First some background: ZAbstractConnection.Disconnect has the following code:
Code: Select all
try
FConnection.Close;
FConnection.SetOnConnectionLostErrorHandler(nil);
finally
FConnection := nil;
end;
1. FConnection.Close - returns the underlying connection to the connection pool.
2. FConnection.SetOnConnectionLostErrorHandler - now because it doesn't have a connection it acquires a new connection that may be unrelated to the connection that was just returned to the pool.
3. FConnection := nil - because it is an interface, it will destroy the object which in turn will return the underlying connection to the pool
The proposed change is very simple:
call FConnection.SetOnConnectionLostErrorHandler(nil); before calling FConnection.Close
I did some basic testing it looks like it doesn't affect other drivers (sqlite)
Comments?