[SERVER-10949] dropDatabase() seems to be killing my connection Edit Created: 27/Sep/13  Updated: 10/Dec/14  Resolved: 19/Mar/14

Status: Closed
Project: Core Server
Component/s: Networking, Stability
Affects Version/s: 2.4.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Tito Ciuro Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS X 10.8.4, Node 0.10.16, MongoDB 2.4.6


Operating System: OS X
Steps To Reproduce:

Adding this snippet to my app breaks all hell loose:

    var databases = developerObject.projects;
    for (var i = 0; i < databases.length; i++) {
        var buildingDatabase = databases[i].name;
        var db = global.MongoDBConnector.db(buildingDatabase);
        console.log('=> dropping building database: ' + db.databaseName);
        db.dropDatabase();
    }

I'm only deleting one database and then this issue happens. If I leave the above snippet out, it all works like a charm.

Participants:

 Description   

Hello,

I have the following setup:

Node v0.10.16
MongoDB 2.4.6

I'm experiencing something really odd with MongoDB's connection and Node: once I issue a dropDatabase command from my Node app, the connection drops from 5 to 0 and MongoDB becomes pretty much useless. Here's the output I see:

    TurboMonkey:momows tito$ mongod
    mongod --help for help and startup options
    Thu Sep 26 20:21:46.796 [initandlisten] MongoDB starting : pid=2710 port=27017 dbpath=/data/db/ 64-bit host=TurboMonkey.local
    Thu Sep 26 20:21:46.796 [initandlisten] 
    Thu Sep 26 20:21:46.796 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
    Thu Sep 26 20:21:46.796 [initandlisten] db version v2.4.6
    Thu Sep 26 20:21:46.796 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
    Thu Sep 26 20:21:46.796 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
    Thu Sep 26 20:21:46.796 [initandlisten] allocator: system
    Thu Sep 26 20:21:46.796 [initandlisten] options: {}
    Thu Sep 26 20:21:46.803 [initandlisten] journal dir=/data/db/journal
    Thu Sep 26 20:21:46.803 [initandlisten] recover : no journal files present, no recovery needed
    Thu Sep 26 20:21:46.820 [websvr] admin web console waiting for connections on port 28017
    Thu Sep 26 20:21:46.820 [initandlisten] waiting for connections on port 27017
    Thu Sep 26 20:21:54.789 [initandlisten] connection accepted from 127.0.0.1:57062 #1 (1 connection now open)
    Thu Sep 26 20:21:54.793 [initandlisten] connection accepted from 127.0.0.1:57063 #2 (2 connections now open)
    Thu Sep 26 20:21:54.794 [initandlisten] connection accepted from 127.0.0.1:57064 #3 (3 connections now open)
    Thu Sep 26 20:21:54.794 [initandlisten] connection accepted from 127.0.0.1:57065 #4 (4 connections now open)
    Thu Sep 26 20:21:54.795 [initandlisten] connection accepted from 127.0.0.1:57066 #5 (5 connections now open)
    Thu Sep 26 20:22:03.368 [conn3] dropDatabase f30cdad4-ecb8-4d9a-85c5-02dd0e4f464b starting
    Thu Sep 26 20:22:03.380 [conn3] removeJournalFiles
    Thu Sep 26 20:22:03.381 [conn3] dropDatabase f30cdad4-ecb8-4d9a-85c5-02dd0e4f464b finished
    Thu Sep 26 20:22:03.381 [conn1] end connection 127.0.0.1:57062 (4 connections now open)
    Thu Sep 26 20:22:03.382 [conn2] end connection 127.0.0.1:57063 (3 connections now open)
    Thu Sep 26 20:22:03.382 [conn3] end connection 127.0.0.1:57064 (3 connections now open)
    Thu Sep 26 20:22:03.382 [conn4] end connection 127.0.0.1:57065 (1 connection now open)
    Thu Sep 26 20:22:03.382 [conn5] end connection 127.0.0.1:57066 (0 connections now open)

From this moment on, the requests "hang" and never come back. I see this with find() and findOne(). What's strange is that even with the auto_reconnect option, MongoDB tries to reopen the connection every ~1 minute but then loses them:

    Thu Sep 26 20:28:54.681 [initandlisten] connection accepted from 127.0.0.1:57190 #24 (1 connection now open)
    Thu Sep 26 20:28:54.681 [initandlisten] connection accepted from 127.0.0.1:57191 #25 (2 connections now open)
    Thu Sep 26 20:28:54.681 [initandlisten] connection accepted from 127.0.0.1:57192 #26 (3 connections now open)
    Thu Sep 26 20:28:54.683 [conn25] end connection 127.0.0.1:57191 (2 connections now open)
    Thu Sep 26 20:28:54.684 [conn24] end connection 127.0.0.1:57190 (1 connection now open)
    Thu Sep 26 20:28:54.684 [conn26] end connection 127.0.0.1:57192 (0 connections now open)

The connection pool is set to 5, but I only see 3 being opened (and then quickly closed) once the dropDatabase() problem has occurred. If I remove the section that performs the dropDatabase, it all works fine:

    var databases = developerObject.projects;
    for (var i = 0; i < databases.length; i++) {
        var buildingDatabase = databases[i].name;
        var db = global.MongoDBConnector.db(buildingDatabase);
        console.log('=> dropping building database: ' + db.databaseName);
        db.dropDatabase();
    }

The other thing I find odd is that I don't see an exception being raised or any type of error. It's a complete silent failure.

Any ideas? Thanks in advance.



 Comments   
Comment by Stennie Steneker (Inactive) [ 19/Mar/14 ]

Hi Tito,

Please be advised I'm now closing this issue as we have been unable to reproduce the reported problem.

If you do have any further information that would help us reproduce this issue (as per the last questions from Luke), please let us know.

Thanks,
Stephen

Comment by Luke Lovett [ 05/Nov/13 ]

Hi Tito,

I'm trying something similar to the code you've provided, but all databases are being dropped for me without loss of connection.

MongoClient = require("mongodb").MongoClient;
 
var databases = ["db1", "db2", "db3", "test"];
MongoClient.connect("mongodb://localhost:27000/test", function(err, client) {
    if (err) throw err;
    for (var dbIndex in databases) {
        var dbName = databases[dbIndex];
        var cont = function(i) { return function(err, done) { console.log("dropped database "+i); }; };
        client.db(dbName).dropDatabase(cont(dbIndex));
    }
});

Are you running mongod as a standalone or as part of a larger system (replica set/sharded cluster)? You might find try to probe the logs a bit more by increasing the verbosity of mongod using the -v(vvvv) flag. If this is still a problem for you, could you try uploading the verbose server logs? We can go from there.

Thanks!

Comment by Tito Ciuro [ 27/Sep/13 ]

I should add that I'm connecting to MongoDB using mongo-native. The connection to MongoDB is performed via MongoClient:

var mongoDBConnector = new MongoClient(new Server(host, port, {
auto_reconnect: true,
native_parser: true,
w: 1
}));

Everything works just fine until I issue a db.dropDatabase().

Generated at Thu Feb 08 03:24:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.