oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
888 stars 361 forks source link

cx_Oracle SessionPool not releasing the connection #398

Closed husseinhussein closed 4 years ago

husseinhussein commented 4 years ago

Greetings,

We have recently upgraded one of our application, Outrider, from cx_Oracle v5.1.3 to v7.3.0. Now, the application is not releasing the connection back to the pool.

Note that the Outrider application is not releasing the connection back to the pool explicitly. It depends on del getting closed. I was just wondering if this is a concern? If not, do you mind helping me out by giving me a high level architecture change between v5.1.3 and v7.3.0 that might be causing this issue.

Note that the database is in Oracle Version 11.2.0.4 and Python Version 2.7.16.

Any help will be appreciated,

Thanks, Hussein

anthony-tuininga commented 4 years ago

A lot has changed between cx_Oracle 5 and cx_Oracle 7, but the biggest changes are due to the use of ODPI-C, which enables cx_Oracle to load the Oracle Client library dynamically, instead of being directly linked as before. That change likely wouldn't cause what you are experiencing, however.

I always make use of the fact that the connection is closed (or returned to the pool) when the connection goes out of scope. This behaviour can be seen in the test suite itself! So this isn't a bug in cx_Oracle. Its possible that you were depending on something specific in the original code which is no longer present in the new code -- but that may be something that you really ought not to have depended on. The first task is to figure out why this is happening and then we can see whether you should change your code or whether I should make changes to cx_Oracle. Without seeing your code, though, I would have no idea why -- so you'll have to help me out here!

husseinhussein commented 4 years ago

Thank you for the response.

I will investigate the issue and provide you with more information.

cjbj commented 4 years ago

@husseinhussein how do you know it 'is not releasing the connection back to the pool'? Are you seeing an error?

husseinhussein commented 4 years ago

That is a good question.

At the moment, all I know is this: When the application tries to acquire another connection from the session pool, the system raises the following error message: ORA-24418: Cannot open further sessions. Note that I have set the maximum connections for the session pool to 2.

When I run the same application with v5.1.3, I don't get the error message. That is the reason why I just wanted to get a high level architecture change to enable me to debug the problem. I read the documentation and I didn't see any changes to SessionPool API that might be causing the error.

Having said that, I will track down the problem and provide more information.

Thanks, Hussein

cjbj commented 4 years ago

That error does sound like an application issue with connections not being released back to the pool. If there was a database limit I would expect a different error.

cjbj commented 4 years ago

Closing - no activity.