vrogier / ocilib

OCILIB (C and C++ Drivers for Oracle) - Open source C and C++ library for accessing Oracle databases

Home Page:http://www.ocilib.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pool connection is never released (C++)

gix opened this issue · comments

The following code hangs in OCISessionGet in the third iteration:

ocilib::Environment::Initialize(ocilib::Environment::Threaded);
ocilib::Pool connPool(db, user, password, ocilib::Pool::SessionPool, 1, 2);

for (int i = 0; i < 3; ++i) {
    ocilib::Connection connection = connPool.GetConnection();
}

The connections are never released to the pool. As far as I can tell, the Connection object is created as transient, and so the HandleDeleter is never called. But maybe I'm doing something wrong.

Brother, write your own thread pool. The performance of the built-in thread pool feels too low or always error-prone. I have given up using it. Write your own thread pool.

Hi,

The code hangs in the 3rd iteration as by default, if the pool is exhausted, requesting a new connection blocks until one is available.
This is expected behavior.
You can change that behavior by using OCI_PoolSetNoWait().

Regards,

Vincent

The code hangs in the 3rd iteration as by default, if the pool is exhausted, requesting a new connection blocks until one is available.

That's not the issue I was describing. The problem is that ~Connection does not release the connection back to the pool. Sample code using a connection also seems to rely on the destructor. Is it required to manually close the connection? If so, the documentation of Close should be clarified and state that a pooled connection is returned and not really closed.

Indeed, I missed that point.

I will investigate.

Regards,

Vincent.

Hi,

This is a bug introduced by commit 8ad2fa4 in v4.7.5.
It is now fixed in v4.7.7 dev branch.

Regards,

Vincent