-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Error "NJS-112: internal error: read integer of length 19 when expecting integer of no more than length 4" when performing SELECT on large amount of rows #1565
Comments
Can you define the term "large"? Since you have set the parameter |
I changed the value of fetchArraySize to 5, and it worked. My issue was that when fetching a large amount of data from a table, I was getting the NJS-112 error. I thought that increasing the fetchArraySize value would allow me to retrieve more rows from the database. I didn't understand why decreasing the fetchArraySize actually resulted in more data being returned by the database. You're very welcome. Happy to help! |
Decreasing the fetchArraySize value was to force the rows to fit within a single packet. It sounds like the logic that handles multiple packets may need some tuning in some edge cases! Since we have not experienced this ourselves are you able to provide the table definition, and if possible, the rows as well? Thanks! |
I'm sorry, but I can't provide the table definition or the rows because they are confidential. However, I can tell you that the table has almost 800 fields and more than 1700 rows of data. |
Ok. If you are able to experiment and see if there is a particular fetchArraySize above which it consistently fails for you, that would be something. We'll try to replicate ourselves but that may prove difficult! |
I'm getting this same error all over my application now: NJS-112: internal error: read integer of length 40 when expecting integer of no more than length 8. What's strange is that it's only happening in production, not test, which are supposed to be exactly the same. Also not happening in my dev environment with same tables but different version of oracle. I'm going to include a stack trace in case that would be helpful: OracleObject.getRefListData Error: NJS-112: internal error: read integer of length 40 when expecting integer of no more than length 8 |
What version of the database are you using? |
12.2 in production and test, 19c in dev. Not seeing the error in dev or test, which is odd since test is 12.2 also. |
@john-hall Have you set any fetchArraySize value for the connections? |
No, I've not set that option. |
I've been continuously encountering this error and have never been successful. It happens regardless of whether the table has only one field or is an empty table.
I get this error when executing const dbConfig = {
user: 'sys',
connectString: '192.168.51.28:1521/ora11g',
password: '123456',
outFormat: oracledb.OUT_FORMAT_OBJECT,
} node: v16.15.1 |
@phantomk The default 'thin mode' of node-oracledb 6 won't connect to Oracle DB 11.2. You need to use Thick mode, see https://node-oracledb.readthedocs.io/en/latest/user_guide/initialization.html#enabling-node-oracledb-thick-mode. Our next version will give a better error message for this scenario. |
@cjbj Which versions of Oracle are supported by the 'thin mode' of node-oracledb 6 |
@phantomk node-oracledb 6.0 Thin mode supports Oracle Database Release 12.1 and later. Please see the following documentation: https://node-oracledb.readthedocs.io/en/latest/user_guide/appendix_a.html#id1 |
@andersonzapaterra, please try this patch. Thanks to @sudarshan12s, we were able to replicate the issue and resolve it: diff --git a/lib/thin/protocol/messages/withData.js b/lib/thin/protocol/messages/withData.js
index 72302b77..b1af419b 100644
--- a/lib/thin/protocol/messages/withData.js
+++ b/lib/thin/protocol/messages/withData.js
@@ -582,7 +582,7 @@ class MessageWithData extends Message {
}
getBitVector(buf, numBytes) {
- this.bitVector = buf.readBytes(numBytes);
+ this.bitVector = Buffer.from(buf.readBytes(numBytes));
}
processBindParams(buf, params) { |
@john-hall @andersonzapaterra You might want to try the patch suggested by @anthony-tuininga here #1565 (comment) |
The patch in |
This is now available as part of node-oracledb 6.0.2. See the release announcement |
Installed the new version (6.0.2) on my server and still received the following error: NJS-112: internal error: read integer of length 40 when expecting integer of no more than length 8 OS: Windows Server 2012R2 Note that I do NOT receive this error on my DEV environment, which is: OS: OSX Ventura 13.4 I also have another server running the exact same versions as the Win2012 server mentioned above and it is NOT seeing the NJS-112 errors with v6.0.2 but is getting the following error: NJS-111: internal error: read a negative integer when expecting a positive integer Let me know if you would like me to perform any additional tests. |
Can you include the full traceback for these errors? Both of those errors (NJS-111 and NJS-112) indicate a lack of synchronization between the client and server in terms of what is being sent by the server. We have noted another instance of this internally and @sharadraju should be able to get that uploaded for you to try soon! |
Unfortunately, now, when trying to reproduce the error to obtain a stack trace, I am receiving the following error: ORA-03106: fatal two-task communication protocol error This is after rolling back to version 5.5.0, which is verified in console at program startup. Not sure how to clear this, perhaps restart database? I had never seen this error prior to trying v6.0.2. |
There should be no need to rollback to 5.5.0. You can simply enable thick mode by calling That said, it would still be useful to get the full traceback for the ORA-3106 as well. Are you dropping/recreating tables, views, etc. when (or just before) this error occurs? Are you using DRCP? |
|
I think the culprit might have been that maxSize value being passed in. I changed it to 32767 and the error stopped happening for that call. Thankfully, that value was defined as a constant and imported when retrieving CLOB or large VARCHAR2 return values. I still have to review all my uses of that constant and make sure that calls that actually return CLOB's have the correct data type specified. But it looks like that solved the problem for me. |
That's good to know! Can you share the PL/SQL function definition? I can then try to replicate that here and resolve the problem properly. Its good to hear you have a workaround, though! Thanks for the packet output. That will be helpful, too. |
Sure, here's the function definition:
|
Thanks. I tried that and returned a small string without difficulty -- but it may be related to the database version as well. |
@john-hall , can you confirm if your application is using callTimeout (conn.callTimeout = 5; // 5msec ) . If its set and you increase it, do you still see the issue? |
My application is not setting callTimeout. Changing the maxSize parameter from 1000000000 to 32767 for the PLSQL function return value fixed the issue for me. What is the default value for callTimeout? |
The default value is |
I tried with an older database just now and it doesn't run into any problems. What is the length of the value that is actually returned? |
The return values can vary from around 400 to approx. 1500... so definitely within max VARCHAR2 (32767) range. |
Update: I've modified our maxStringSize constant to 32767 and added a maxClobSize constant based on Oracle docs:
I also updated our app to use the correct constant based on the return data type of each PLSQL package function being called (there are hundreds!). Note: this Node application is a replacement for a PLSQL-based web application that used the now depricated OHS web toolkit (mod_plsql). I've commented out the oracledb.initOracleClient() line and executed our entire test suite in "thin" mode with no errors! Thank you VERY much for your patience in helping resolve this issue! It will be a great advantage to run out app in thin mode so we won't have to install the Oracle Client libraries in the host environement anymore! |
With further thin mode testing, I'm now encountering the following error:
Here is the SQL that produced the error:
Let me know if I should open a separate issue for this. |
Yes, please do open another issue with this information. How many rows are being returned? Please post the packet output on the new issue, too. Looks like this may be LOB related, too! If you are able to demonstrate the problem with a standalone test case that would be ideal. |
Ok, will do. Thanks. Having a hard time reproducing this one... seems to be intermittent and goes away when I turn on the packet tracing. This makes me think it may be timing related. I'll submit a new issue if I can reproduce in a consistent way and get a packet trace. |
Regardng this issue, I can verify that there is a problem with how the client is interpreting the LOB values that are being returned when you set maxSize > 32767. We are continuing to investigate this but your solution is the correct one regardless! |
Thanks Anthony. I have reverted to using v6.0.2 in "thick" mode because the NJS-111 error is very sporadic and difficult to reproduce consistently... but it continues to happen in our application. I will continue to monitor the issues/releases and try to contribute whenever possible. |
I understand. Hopefully the issue above is something we can figure out and resolve and you can try your application again after that. |
@john-hall , Can you provide a standalone inserting some rows and return it from pl/sql function. I started something like below to capture the specifics and tried multiple changes to it but could not reproduce. . Please modify/fill as you notice specific to your case.. Thanks.
|
@john-hall node-oracledb 6.0.3 has been released. Please try the use case with the patch. |
@sharadraju: I encounter this error message with version 6.0.3 NJS-112: internal error: read integer of length 31 when expecting integer of no more than length 4 at position 313 of packet 210 No Problems with the thick client though |
@ertl Please provide us a reproducible test case and also let us know your OS platform and Oracle Database version details. |
@sharadraju: Can't tell cause I'm struggeling with some ORA-01002: fetch out of sequence With the db driver version 6.0.2 I get an ORA-01002 Error before I come to the NJS-112 part. All Tests pass with the thick driver tought. If you want to have a look on it, the error is reproduceable in the branch (https://github.com/ertl/typeorm/tree/feat-oracledb6) Before you run the tests:
P.S: |
Thanks @ertl for providing the details. It is very helpful. I see We are working on this and would share more details soon. |
I am encountering an issue when using the node-oracledb library to perform a SELECT query on a large number of rows in my Oracle table. The error I'm getting is:
NJS-112: internal error: read integer of length 19 when expecting integer of no more than length 4
Here are the details:
Environment:
Node.js 18
node-oracledb version: 6.0.0
SQL Query:
I'm executing the following SQL query:
Note: The error occurs when the query returns a large number of rows. If the query returns only a small number of rows, the error does not occur.
fetchArraySize setting:
I've tested by changing the fetchArraySize setting, but the error still occurs when the number of rows is large.
Attempted resolutions:
I've tried changing the fetchArraySize, but the problem persists.
I've also checked to see if there's enough memory space, and it seems that there is.
code:
The text was updated successfully, but these errors were encountered: