Exception in Mongo java client 2.4 - mongodb

My pc is running with mongo 1.6.5 .
One of my collections has 973525 records
when I try to find distinct key on that collection its giving me Exception
the query is
db.collection.distinct("id")
java.lang.IllegalArgumentException: 'ok' should never be null...
at com.mongodb.CommandResult.ok(CommandResult.java:30)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:60)
at com.mongodb.DBCollection.distinct(DBCollection.java:756)
at com.mongodb.DBCollection.distinct(DBCollection.java:741)
at com.test.TestMongo$.<init>(TestMongo.scala:26)
at com.test.TestMongo$.<clinit>(TestMongo.scala)
at com.test.TestMongo.startTesting(TestMongo.scala)
at com.test.Main.main(Main.java:13)
And when i try same query in mongo terminal gives error
Thu Mar 10 21:40:20 uncaught exception: error { "$err" : "Invalid BSONObj spec size: 8692881 (91A48400)", "code" : 10334 }

This error comes when you have a document that is too large. You can upgrade to 1.8 where the max document size is 16MB. Mongo 1.6x has max size of 8MB which that document is slightly larger than. You may be able to solve this in a repair (run mongod --repair, may take a long time).

Related

MongoDB Error when querying a capped collection

I need some help interpreting/resolving this error:
OperationFailure: Executor error during find command :: caused by :: errmsg: "CollectionScan died due to position in capped collection being deleted. Last seen record id: RecordId(225404776)"
which occurs when I run this command:
mongodb_connection["databaseName"]["cappedCollectionName"].find(query)
The mongodb instance is a "single" instance, and we are querying a "capped" collection. The query is looking at recent data, which should be in the DB (and not written over via the cap).
Thanks!

Invalid access on Mongo 3.0

Problem happened in Development site. Following query crashes server with Invalid access at 0x20:
db['2015-04-13'].group({
key:{id:1},
cond:{created_at:{$gte: new Date('2015-04-13')}},
reduce:function (curr, resul) {},
initial: {}
})
Traceback:
mongod(_ZN2v88internal2OS8AllocateEmPmb+0xD7) [0x11dbe57]
mongod(_ZN2v88internal28CreateTranscendentalFunctionENS0_19TranscendentalCache4TypeE+0x26) [0x12799f6]
mongod(_ZN2v88internal22init_fast_sin_functionEv+0xE) [0x11dca1e]
mongod(_ZN2v88internal14POSIXPostSetUpEv+0x9) [0x11dd009]
mongod(_ZN2v88internal2V828InitializeOncePerProcessImplEv+0x3E) [0x12551de]
mongod(_ZN2v88internal12CallOnceImplEPlPFvPvES2_+0x52) [0x11c2c12]
mongod(_ZN2v88internal2V810InitializeEPNS0_12DeserializerE+0x11) [0x1255911]
mongod(_ZN2v86LockerC1EPNS_7IsolateE+0x61) [0x12597c1]
So far i know:
Problem occurs only when mongod runs as it's own user (mongod).
If mongod started as root on same data folder, query passes and return results. Number of documents in collection is fairly small (around 20k), but there is decent number of keys for each - 50 in average, and 300 at most, most of them Strings with very few BSONs. MongoDB version is 3.0.2, query was passed as though local client with same version as server, as though 2.4.0 Robomongo client on remote machine - error appears in both cases.

Mongo DB throws Runner error What does that mean?

Mongo Db 2.4.6 on Windows 7 64bit throws Runner error: Overflow sort stage buffered data usage of 34371341 bytes exceeds internal limit of 33554432 bytes.
I am new to mongo and dont know how to resolve this issue.

mongo shell throwing error while running "show collections" command

My mongo shell is starting without any error
>use mydb is also working properly (here db name is mydb)
but when i am giving show collections command, it is showing following error.
>show collections
Wed Oct 15 17:38:30 uncaught exception: error: {
"$err" : "file /var/lib/mongodb/mydb.6 open/create failed in createPrivateMap (look in log for more information)",
"code" : 13636
}
Here is the error log
17:38:22 [initandlisten] connection accepted from 127.0.0.1:53178 #1
17:38:30 [conn1] ERROR: mmap private failed with out of memory. You are using a 32-bit build and probably need to upgrade to 64
17:38:30 [conn1] Assertion: 13636:file /var/lib/mongodb/mydb.6 open/create failed in createPrivateMap (look in log for more information)
17:38:30 [conn1] assertion 13636 file /var/lib/mongodb/mydb.6 open/create failed in createPrivateMap (look in log for more information) ns:mydb.system.namespaces query:{}
17:39:01 [clientcursormon] mem (MB) res:2 virt:90 mapped:0
Based on one solution given for another stackoverflow question ,couldn't connect to server 127.0.0.1 shell/mongo.js , i tried same step in my case and problem was solved for time being, but the main issue is whenever i shutdown my machine and restart again i get the same error and i have to repeat same steps (as given in above link) to make mongo shell working and it ultimately lead to data loss within collections. Can anyone suggest what could be the reason , is there some problem with my mongodb installation? Please let me know if anyone had similar issue and successfully resolved it . Thanks
I think there's two possible sources of the problem:
your computer doesn't have enough RAM available
as the log message says, you are using a 32-bit build of MongoDB and should use a 64-bit build, because you have two much data to memory map with 32-bit (> about 2.5 GB)

mongodb sharded collection query failed: setShardVersion failed host

I have encountered a problem after adding a shard to mongodb cluster.
I did the following operations:
1. deploy a mongodb cluster with primary shard named 'shard0002'(10.204.8.155:27010) for all databases.
2. for some reason I removed it and add a new shard of different host (10.204.8.100:27010, was automaticlly named shard0002 too) after migrating finished.
3. then add another shard (the one removed in step 1), named 'shard0003'
4. executing query on a sharded collection.
5. the following errors appeared:
mongos> db.count.find()
error: {
"$err" : "setShardVersion failed host: 10.204.8.155:27010 { errmsg: \"exception: gotShardName different than what i had before before [shard0002] got [shard0003] \", code: 13298, ok: 0.0 }",
"code" : 10429
}
I tried to rename the shardname, but it's not allowed.
mongos> use config
mongos> db.shards.update({_id: "shard0003"}, {$set: {_id: "shard_11"}})
Mod on _id not allowed
I have also tried to remove it, draining stared but processing seems hung up.
what can I do ?
------------------------
lastupate (24/02/2014 00:29)
I found the answer on google. since mongod has it's own cache for mongod configuration, just restart the sharded mongod process, the problem will be fixed.