Page 1 of 1

TConnectionPool - Performance issue

Posted: 06.04.2022, 14:20
by stoffman
A connection is being checked twice for being dead (by calling FConnections.Rollback) . Both when it is Acquired and when it is being returned to
the pool (see TConnectionPool.ReturnToPool and TConnectionPool.Acquire ).

Calling rollback is expensive.

I believe that TConnectionPool.ReturnToPool call is redundant. And removing it will not change the way applications actually work.


Thanks,
Yoni

Re: TConnectionPool - Performance issue

Posted: 07.04.2022, 10:22
by marsupilami
Hello Yoni,

did you check that removing the call actually improves performance in your setup? Just out of curiosity: Which database / zeos driver do you use?

Best regards,

Jan

Re: TConnectionPool - Performance issue

Posted: 11.04.2022, 11:00
by stoffman
Hi,

Sure. I removed the code and it does improve the performance. I'm using the PostgreSQL driver (connecting to server v13.2).

Doing a rollback is very expensive, as you have a full roundtrip to the server .


As aside note, there is also a bug that can lead to connection leakage when doing a rollback and the connection is set to AutoCommit, PostgreSQL throws an exception stating that an AutoCommit connection cannot be rolledback, then TConnectionPool.ReturnToPool marks this connection as unusable and obtains a new one while not closing or releasing the first