oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.24k stars 1.07k forks source link

`getData()` on a `BLOB` fails in 6.0.0 and above when attempting to get data from an AQ message payload #1571

Closed nicholas-ochoa closed 1 year ago

nicholas-ochoa commented 1 year ago

When attempting to retrieve data from a BLOB on a queue message payload, an exception is encountered in the node-oracledb driver that prevents the data from loading. This worked on 5.5.0 without any issues. I'm using the thick client in this case, because the 6.x.x thin client does not yet support Oracle Advanced Queues.

  name: 'TypeError',
  message: "Cannot read properties of undefined (reading '_parentObj')",
  stack: "TypeError: Cannot read properties of undefined (reading '_parentObj')\n" +
    '    at LobImpl._getConnImpl (C:\\git\\blob-issue\\6.0.1\\node_modules\\oracledb\\lib\\impl\\lob.js:43:29)\n' +
    '    at Lob.<anonymous> (C:\\git\\blob-issue\\6.0.1\\node_modules\\oracledb\\lib\\util.js:154:29)\n' +
    '    at Lob.<anonymous> (C:\\git\\blob-issue\\6.0.1\\node_modules\\oracledb\\lib\\util.js:176:25)\n' +
    '    at Lob.wrapper (C:\\git\\blob-issue\\6.0.1\\node_modules\\oracledb\\lib\\util.js:123:19)\n' +
    '    at main (C:\\git\\blob-issue\\6.0.1\\index.js:42:31)'

Version details:

process.platform: win32
process.version: v18.16.0
process.arch: x64
versionString: 5.5.0 and 6.0.1
oracleClientVersionString: 19.11.0.0.0

I've created a repo containing a reproduction of the issue, along with SQL scripts to recreate the database schema, objects and procedures: https://github.com/nicholas-ochoa/node-oracledb-blob-issue

cjbj commented 1 year ago

Thanks for the report. We'll look into it.

pvenkatraman commented 1 year ago

Both examples show deqOne() call, is there another script calling enqOne()? Thanks

cjbj commented 1 year ago

@pvenkatraman the enqueue is done in SQL, if I read the files correctly

pvenkatraman commented 1 year ago

@cjbj, yes noticed enqueue () in db/create-proc.sql, but there is also a dequeue() in the same file, so whatever queued, will be processed there itself.

nicholas-ochoa commented 1 year ago

I apologize for the confusion - I created this from a portion of a much larger / complex application.

The workflow in the actual application looks like this:

  1. Server starts and listens on queue ATTACHMENT with correlation UPLOAD
  2. Client sends a message to queue ATTACHMENT with correlation UPLOAD containing a payload, which also includes the client SESSIONID, in this example let's say that is 87654321.
  3. Server receives the message and processes it. (this is where the failure is happening, in my application and in this example)
  4. Server sends a message to the queue ATTACHMENT with correlation 87654321 (the client SESSIONID).
  5. Client receives the message and handles accordingly (success / failure, timeout, etc).

I have updated my example repo to remove step 5, which is the dequeue() call you were seeing in the create-proc.sql script. In this example it would not be needed and was never getting used; I had already removed the enqOne() call (step 4) from the JavaScript portion of the example.

cjbj commented 1 year ago

@pvenkatraman I read it wrong !

nicholas-ochoa commented 1 year ago

Were you able to reproduce the issue with the repo / notes I provided? If not, I can try and further clarify - or try and further simplify the example repo. Unfortunately, this issue is blocking us from updating to the newer releases of the driver.

anthony-tuininga commented 1 year ago

Yes, we can reproduce it. It isn't specific to AQ at all, either! We'll get back to you on a solution once we have it!

sharadraju commented 1 year ago

@nicholas-ochoa This has been fixed. And here is the patch:


index 5cc9091c..93d41809 100644
--- a/lib/connection.js
+++ b/lib/connection.js
@@ -146,6 +146,7 @@ class Connection extends EventEmitter {
       cls = this._buildDbObjectClass(objType);
       cls._connection = this;
       cls._objType = objType;
+      objType._connection = this._impl;
       this._dbObjectClasses.set(objType, cls);
     }
     return (cls);
sharadraju commented 1 year ago

The fix will be available as part of the 6.0.2 release

nicholas-ochoa commented 1 year ago

I tested the patch in my example reproduction and it fixes the issue. Thank you!

sharadraju commented 1 year ago

This is now available as part of node-oracledb 6.0.2. See the release announcement