KonnexionsGmbH / OraLixir

Oracle driver for Elixir
Other
2 stars 4 forks source link

maximum cursors issue and no means to cleanly close connection. #15

Closed jaman closed 6 months ago

jaman commented 7 months ago

I have been attempting to make use of OraLixir/Oranif to connect to dozens of oracle databses, and have found an issue.

There is a query that I must fire off about once very five seconds across all of the databases. In this OraLixir is great, as I can do that in a couple of milliseconds. The problem comes in that, after about one and a half ours of queries, individual connections begin to report that I have reached the maximum number of allowed open cursors. Not all databases reach the limit at the same time, leading me to believe that the issue may simply be some race condition for which cursors may end up being left open. I amsimply doing OraLixir.prepare_execute(connection, 'connection_id', query, params, options) for options I've tried rand_exp backoff with a min time of 30 seconds and a max_restarts of 0

To further add to this, I cannot find any means by which to cleanly request that the connection be closed/disconnected. I'd like to disconnect the connection, and re-establish it when max cursors are reached if there is no simple means by which to prevent the max cursors issue. Attempting DBConnection.close(connection, query) does not disconnec the connection from the database.

Please let me know if there is something I'm missing.

Thank you.

jaman commented 6 months ago

Resolved issue in my fork. The handle_execute callback calls stmt_execute, but we never get a stmt_close, so cursors are left open. I added a stmt_close call after the execute_query call.

Was able to clearly see this, as it results in a memory leak, one that can easily be spotted if you're querying a large number of databases every few seconds.