node-oracle icon indicating copy to clipboard operation
node-oracle copied to clipboard

connection.commit() SegFault

Open felipeaf opened this issue 11 years ago • 3 comments

Hi!

All my calls for commit() close node with Segmentation Fault. I tested this with setAutoCommit(false).

I tested with Instant Client 12.1

Example:

var oracle = require("oracle")
var INSERT_EXAMPLE= ... //wherever

oracle.connect(connectData, function(err, connection) {
    if (err) { console.log("Error connecting to db:", err); return; }

    connection.setAutoCommit(false)

    connection.execute(INSERT_EXAMPLE, [], function(err, results) {
        if (err) { console.log("Error executing query:", err); return; }

        //WILL SEGFAULT HERE!!!
        connection.commit(function(err) {
            console.log("callback commit")
            console.log(err)
        });
        connection.close(); // call only when query is finished executing
    });
});

felipeaf avatar Feb 17 '14 18:02 felipeaf

please put the connection.close() inside the commit callback. You are probably closing the connection before the commit happens.

Shouldnot result in a SegFault, but might be the cause

kontrafiktion avatar Feb 17 '14 18:02 kontrafiktion

ok, was wrong here, but i have segfault yet in commit().

My workaround is replace commit and close functions for:

connection.execute("commit", [], function (err, results) {console.log(err); connection.close();} )

felipeaf avatar Feb 18 '14 18:02 felipeaf

I'm running into this as well, with both commit and rollback on node v0.8.14 and v0.8.21. I've confirmed that doing an execute('commit'...) or execute('rollback', ...) appears to work. I don't close connection at all, since I'm using generic-pool, so it's probably not related to connection.close().

mwolson avatar Feb 18 '14 19:02 mwolson