Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pool connection is never released (C++) #355

Open
gix opened this issue Nov 7, 2023 · 5 comments
Open

Pool connection is never released (C++) #355

gix opened this issue Nov 7, 2023 · 5 comments

Comments

@gix
Copy link

gix commented Nov 7, 2023

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.

@MagicXran
Copy link

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.

@vrogier
Copy link
Owner

vrogier commented Apr 17, 2024

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

@vrogier vrogier closed this as completed Apr 17, 2024
@gix
Copy link
Author

gix commented Apr 17, 2024

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.

@vrogier
Copy link
Owner

vrogier commented Apr 17, 2024

Indeed, I missed that point.

I will investigate.

Regards,

Vincent.

@vrogier vrogier reopened this Apr 17, 2024
vrogier pushed a commit that referenced this issue Apr 19, 2024
@vrogier
Copy link
Owner

vrogier commented Apr 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants