mariano / node-db-oracle

Oracle database bindings for Node.js
http://nodejsdb.org
141 stars 34 forks source link

Connection flushing? #38

Open fabiob opened 12 years ago

fabiob commented 12 years ago

I'm working on a simple service that receives uploaded files, stores them on the disk and records some metadata on an Oracle table. I'm using the db-oracle package together with connection pooling, following this article: http://nodejsdb.org/2011/05/connection-pooling-node-db-with-generic-pool/

However, I've noticed that the data I insert is only sent to the Oracle database after the connection pool closes the idle connection, by calling its disconnect() method.

I need a way to flush the data before sending the 'OK' signal to my client, otherwise a crash on my webservice or on Oracle itself can cause loss of data. I actually tested this by killing my app process after some uploads, and the data was indeed lost.

As a workaround, I've tried to implement a fake connection pool and release all acquired connections, but now my app is dying with the message: pure virtual method calledAbort trap: 6

Here's the fake connection pooling:

var fakePool = {
  acquire: function(callback) {
    new oracle.Database(config.database).connect(function(err, server) {
      callback(err, this);
    });
  },
  release: function(conn) {
    conn.disconnect();
  }
};

Just to be clear, I don't care about the fake connection pooler, the real problem is the absence of a flush() method or something similar.