Git Product home page Git Product logo

Comments (8)

tgulacsi avatar tgulacsi commented on May 30, 2024

See 7601cc0 (Test_open_cursors_db) for a reproducing case.

from ora.

rana avatar rana commented on May 30, 2024

I do suspect the driver of keeping open cursors, but am unsure if it is. It certainly sounds like it. I initially looked into it but wasn't able to find out how to solve it.

from ora.

tgulacsi avatar tgulacsi commented on May 30, 2024

It is the same with non-driver code: see Test_open_cursors in z_session_test.go

Why is this automatic ResultSet management? I'm not sure that not that's the problem's source...

from ora.

rana avatar rana commented on May 30, 2024

I think you're right. Its a general issue not specific to database/SQL.
Automatic rset management was added for database/SQL and general ease of
use. If auto management is the issue it should be fixed or removed.

It might be related to rset pooling or at the oci level. When I looked at
open cursors in oracle they would be reduced after time. So, does that mean
the driver opens them quickly and oracle eventually cleans them up? Or
is there a leak?

I will have a closer look at test_open_cursors.

On Tue, Jun 2, 2015, 2:39 AM Tamás Gulácsi [email protected] wrote:

It is the same with non-driver code: see Test_open_cursors in
z_session_test.go

Why is this automatic ResultSet management? I'm not sure that not that's
the problem's source...


Reply to this email directly or view it on GitHub
https://github.com/rana/ora/issues/21#issuecomment-107893918.

from ora.

tgulacsi avatar tgulacsi commented on May 30, 2024

I've added Test_open_cursors_db to goracle, and there it passes.
Goracle uses OCIStmtPrepare2 & OCIStmtRelease; I've tried to add it to ora, but didn't work: after OCIStmtPrepare2 (instead of OCIStmtPrepare), I get ORA-24337: statement handle not prepared.
In retrospect, maybe that's because of how I declared the pointer to ocistmt.

Now I've tried it again, and WORKS! See my PR.

from ora.

rana avatar rana commented on May 30, 2024

Awesome!

from ora.

rana avatar rana commented on May 30, 2024

I was reviewing the open cursor issue, docs and tests.

Statement Caching in OCI says that OCIStmtPrepare2 must be followed with a call to OCIStmtRelease. And according to Oracle, "A call to OCIStmtPrepare2(), even if the session does not have a statement cache, also allocates the statement handle. Therefore, applications using only OCIStmtPrepare2() must not call OCIHandleAlloc() for the statement handle."

Separately, OCIStmtPrepare can be followed by a call to OCIHandleFree.

If you want to read more about it, the Oracle docs have some good guidance on the matter.

I also fixed a bug in Test_open_cursors to use 'opened cursors current' STATISTIC#=5 to determine the number of open cursors. I think this issue is closed due to your bug fix. In my test, The number of open cursors was 2 before the test and 3 after the test. The increase in cursor count was due to querying the number of cursors.

So your code fixed the issue. Thank you!

from ora.

tgulacsi avatar tgulacsi commented on May 30, 2024

I've read that paragraph several times, but it doesn't say why an OCIStmtPrepare + OCIHandleFree would leave cursors open...

Anyway, thanks for the cleanup!

from ora.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.