Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8126389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:07:54+00:00 2026-06-06T07:07:54+00:00

I’m working on a simple service using Node.js. It receives uploaded files, stores them

  • 0

I’m working on a simple service using Node.js. It 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.

Is there a way to flush the data before sending the ‘OK’ signal to my client? The way it is working now, a crash on my webservice or on Oracle itself can cause loss of data, and the client of my service would not know about it. I actually tested this by killing my app process after some uploads, and the data was indeed lost.

Here’s a simplified version of the code:

var express = require('express');
var app = module.exports = express.createServer();

app.post('/upload', handleUpload);

app.listen(4001, function(){
  console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});

function handleUpload(req, res) {
  res.contentType('application/xml');

  var buf = '';
  req.on('data', function(chunk) { buf += chunk; });
  req.on('end', function() {
    saveUpload(req, res, buf);
  });
}

function saveUpload(req, res, buf) {
  if (buf.length == 0)
    return sendError(res, 'No data supplied', 422);

  var payload = new Buffer(buf, 'base64');

  files.save(payload, function(err, savedFile) {
    if (err)
      return sendError(res, 'Error while saving', 500);

    var obj = { ip: req.connection.remoteAddress, location: savedFile.path,
                created_at: new Date(), updated_at: new Date() };

    var fields = ['IP', 'LOCATION', 'CREATED_AT', 'UPDATED_AT'];
    var values = fields.map(function(v) { return obj[v.toLowerCase()] });

    pool.acquire(function(err, conn) {
      if (err)
        return sendError(res, err, 500);

      var q = conn.query().insert('FILES', fields, values);

      q.execute(function(err, result) {
        pool.release(conn);

        if (err)
          return sendError(res, err, 500);

        if (result.affected < 1)
          return sendError(res, 'Error saving the record', 500);

        // The next statement sends the final result to the client.
        // However, the new record was not yet flushed to the database.
        res.end('<ok />');
      });
    });
  });
}

function sendError(res, err, code) {
  console.log(err);
  res.send('<error>' + err + '</error>', code || 500);
}

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, it was just a dirty workaround. I want to be able to flush the data to Oracle before sending the ‘OK’ to my client.

Btw I also opened a ticket on their Github: https://github.com/mariano/node-db-oracle/issues/38

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:07:56+00:00Added an answer on June 6, 2026 at 7:07 am

    You are obviously missing a transaction commit.

    node-db does not need to expose a commit API because in most RDBMS (including Oracle), COMMIT is a valid query. Since the package allows the execution of arbitrary queries, commit/rollback are supposed to be done using a simple execute()

    The code should be changed as follows:

    pool.acquire(function(err, conn) {
      if (err)
        return sendError(res, err, 500);
    
      var q = conn.query().insert('FILES', fields, values);
      q.execute(function(err, result) {
    
        if (err || result.affected < 1 ) {
           pool.release(conn);
           return sendError(res, err, 500);
        }
    
        conn.query().execute("commit", function(err,result) {
          if (err) {
            pool.release(conn);
            return sendError(res, err, 500);
          }
          res.end('<ok />');
          pool.release(conn);
        });
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.