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
Reconnect to Oracle not working for queries #3373
Comments
@vpeltola Would you consider submitting PR with test for this? |
I'm using knex for my project and it seems knex does have intermittent issues reconnecting to the oracle database. I think, the code for oracle dialect could be improved to resolve this. If you refer the code below, knex/lib/dialects/oracledb/index.js Lines 131 to 145 in f782348
And it is set only for select statements and not other variants of select statement like knex/lib/dialects/oracledb/index.js Lines 253 to 255 in f782348
IMO, resolution will be to move the Moreover, the error codes included are not correct. All oracle error codes starting with ORA are of 5 digits. For example knex/lib/dialects/oracle/utils.js Lines 44 to 79 in f782348
|
اعاده. ظبط القارب. وشكرا |
@kibertoad can I raise a PR for this ? |
@abskmj this has been tried to be fixed couple of times already some kind of integration test would be nice to be included if you start fixing this. |
I will start with a simple PR which has the right ORA codes. Do I need to create separate issues to resolve this with multiple PRs? |
Thanks! The whole bug should be fixed in a single PR. |
ORA codes are corrected part of PR #3498 |
@vpeltola Could you please try 0.20.1 and see if problem was fixed? |
Hello! |
Environment
Knex version: 0.19.1
Database + version: 12.2.0.1
OS: Fedora 30
@atiertant
Bug
If an oracle database is restarted, knex (still) loses the connection and is unable to reconnect in some cases, specifically at least when performing queries.
knex version 0.18 attempted to fix this problem in issue #2608 in this commit
6e5e296
ORA-xxxx error messages were added to the isConnectionError(err) function in knex/lib/dialects/oracle/utils.js file. The function checks if err.message starts with a specific ORA-xxxx or NJS-xxx error message and if so returns true.
However, this does not always work. For example, when attempting to run a query after a database restart, the connection error is not detected, because the err.message string looks like this:
As stated before, isConnectionError() requires "ORA-03113" to be at the very beginning of the message, which is how it comes out of the oracledb module.
The root of problem seems to be caused by knex/lib/client.js function query(), which prepends the query to err.message (knex version 0.19.1):
If line 160 was reversed so that the original database error message came first, then the isConnectionError() function should work (or even better, don't change err.message at all)
The text was updated successfully, but these errors were encountered: