[SERVER-7041] DBClientCursor::init call() failed Created: 14/Sep/12 Updated: 03/Jul/13 Resolved: 01/Oct/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | 2.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Goran Nikolovski | Assignee: | Gregor Macadam |
| Resolution: | Done | Votes: | 1 |
| Labels: | crash, driver | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
O.S: Ubuntu 11.04, |
||
| Attachments: |
|
| Operating System: | Linux |
| Participants: |
| Description |
|
I have developed server application in C++ using the v2.2.0 c++ driver for establishing connections to MongoDb. |
| Comments |
| Comment by Ian Whalen (Inactive) [ 09/Oct/12 ] |
|
dbabits, please open a new SERVER ticket with your issue so that we can track it (and tie it back to this ticket if appropriate.) |
| Comment by david babits [ 09/Oct/12 ] |
|
I am getting the same problem while using official mongo client: src/mongo/shell/mongo.js:93 /home/hprspkg/hprs_3rd_party/mongodb-linux-x86_64-static-legacy-2.2.0/bin/mongo localhost:28017/mydb --quiet --eval 'db.mytable.find({id:{$in:["jq_2395764120","jq_2395764121"]}}.forEach(printjson); server was shutdown prior with CTRL-C |
| Comment by Gregor Macadam [ 01/Oct/12 ] |
|
Resolving as "works as designed" - feel free to reopen if you don't feel this is the case. |
| Comment by Randolph Tan [ 22/Sep/12 ] |
|
I am saying that the MongoConnection shouldn't have a ScopedDbConnection as a member variable (unless you make your class non-copyable, in fact, we should have made ScopedDbConnection non copyable). I'll show you why the current code is dangerous: MongoConnection conn; // since you are not passing by reference here, a copy is created, at this point there are 2 different objects that has a pointer to the ScopedDbConnection, Note that the copy has a scope that is only within the inserting function. So when the function terminates, it will call the MongoConnection destructor, which will in turn attempt to destruct the ScopedDbConnection (which you now placed a flag to hack around this). |
| Comment by Aleksandar [ 22/Sep/12 ] |
|
At our project each of the server's clients (i.e. threads) get their own instance of MongoConnection. There is no double free, the problem occurs when I try to call done() and delete for specific ScopedDBConnection. If in meantime the connection to the primary node failed (primary node goes down), looks like the memory where the ScopedDBConnection pointer points gets corrupted. If you try to call done() and delete on that same pointer, the result is SIGABRT. The check that we perform for NULL in the destructor of MongoConnection was just a quick guess that we do double free. However, this did not solve the problem, adding some sort of flag that the connection to the primary node failed, did solve the problem but with possible memory leaks. |
| Comment by Randolph Tan [ 21/Sep/12 ] |
|
I took a glance at your code and noticed that you are storing the ScopedDBConnection to the MongoConnection class. This is ok as long as you don't share the connection and don't share the pointer around (This is probably what caused the crash. ScopedDBConnection is not meant to be copied and doing a shallow copy of ScopedDBConnection can cause double free). |
| Comment by Aleksandar [ 21/Sep/12 ] |
|
Here is a link to a simple project that we just wrote, http://dl.dropbox.com/u/15196029/MongoSample.tar.gz . It performs basically the same operations to mongodb as in our project and we managed to find the cause of the problem. |
| Comment by Gregor Macadam [ 20/Sep/12 ] |
|
Is this easily reproducible for you? I've tried to reproduce it with a small program using DBClientReplicaSet to connect to the replica set. I have three nodes with priorities 3,2,1. I don't get a SIGABRT however. Is there some code you could attach that can reproduce this? |
| Comment by Aleksandar [ 19/Sep/12 ] |
|
Handling the NULL cursor case seems that it has resolved the issue without replica set. |
| Comment by Randolph Tan [ 18/Sep/12 ] |
|
DBClientCursor::init call() is a log message that appears when the driver cannot initialize the cursor. And it will make the query return a NULL DBClientCursor pointer. Does your application handle the NULL cursor case? |
| Comment by Aleksandar [ 18/Sep/12 ] |
|
I just tried catching the signal, it resulted in SIGABRT. This situation is more likely to happen when you perform higher number of operations to mongodb i.e. when server is under load. |
| Comment by Aleksandar [ 18/Sep/12 ] |
|
I have the same problem with the v2.2.0 C++ driver. I tested with and without replica set and got the same result. When using replica set if the primary node goes down (Ctrl + C) the application results in "DBClientCursor::init call() failed" and no exception can be caught in my application, looks like the driver sends some signal. |