timisbusy / dumpstr

A node.js package to dump mongodb (mongodump) directly into s3 without filling up your local disk in the process.
MIT License
16 stars 6 forks source link

Mongodb open connections #2

Open sprijk opened 9 years ago

sprijk commented 9 years ago

Hey, the current dumpstr library never closes any database connections, therefor it leaves 5 open connections per database that you backup. I use this library to backup my database on a daily base and I noticed on my monintoring system that every time I run the back up, the open connections were increased by 5 per database.

Fix in mongoInfo.js

var MongoClient = require('mongodb').MongoClient;

function getCollections (uri, cb) { establishConnection(uri, function (err, client) { if (err) { return cb(err); } client.collectionNames(function(error, result) { cb(error, result); client.close(); }); }); }

function establishConnection (uri, cb) {

MongoClient.connect(uri, cb);

}

module.exports = { getCollections: getCollections }