mongo bug? (c# driver)

51 views
Skip to first unread message

Harvester of Sorrow

unread,
Sep 29, 2011, 2:25:32 AM9/29/11
to mongodb-user
given this code :

MongoServer s = MongoServer.Create();
var col = s.GetDatabase("hhhh").GetCollection("dsssss");
List<int> arr = new List<int>();
for (int i = 0; i < 40000; i++)
{
arr.Add(i);
}

for (int i = 0; i < 100; i++)
{
BsonDocument doc = new BsonDocument();
doc.Add("1", BsonInt32.Create(1));
doc.Add("2", BsonInt32.Create(1));
doc.Add("3", BsonInt32.Create(1));
doc.Add("4", BsonInt32.Create(1));
doc.Add("5", BsonInt32.Create(1));
doc.Add("6", BsonInt32.Create(1));
doc.Add("7", BsonInt32.Create(1));
doc.Add("8", BsonInt32.Create(1));
doc.Add("9", BsonInt32.Create(1));
doc.Add("dd", BsonArray.Create(arr));
col.Insert(doc);
}

for (int i = 0; i < 100; i++)
{
col.FindOne();
}

col.CreateIndex("dd");

At createindex the mongo.exe starts working really hard, and the c#
driver dies with a transport error in ReceiveMessage<TDocument>.
I'm using driver 1.1, mongo 2.0, x64 bits.

thanks

Nat

unread,
Sep 29, 2011, 3:15:59 AM9/29/11
to mongod...@googlegroups.com
Can you check your mongodb server log to see whether there is any error. Can you also get db.<YourCollection>.stats()
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Harvester of Sorrow

unread,
Sep 29, 2011, 4:59:45 AM9/29/11
to mongodb-user
error is :

Unable to read data from the transport connection: A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond.

internal MongoReplyMessage<TDocument> ReceiveMessage<TDocument>(
BsonBinaryReaderSettings readerSettings,
IBsonSerializationOptions serializationOptions
)

After aprox 2 minutes, mongo si around 40-50% CPU (AMD Phenom 2 X4
945), and the log is :

Thu Sep 29 11:51:31 [initandlisten] MongoDB starting : pid=3512
port=27017 dbpath=c:\mongo\data 64-bit host=RSL5WS
Thu Sep 29 11:51:31 [initandlisten] db version v2.0.0, pdfile version
4.5
Thu Sep 29 11:51:31 [initandlisten] git version:
695c67dff0ffc361b8568a13366f027caa406222
Thu Sep 29 11:51:31 [initandlisten] build info: windows (6, 1, 7601,
2, 'Service Pack 1') BOOST_LIB_VERSION=1_42
Thu Sep 29 11:51:31 [initandlisten] options: { bind_ip: "127.0.0.1",
dbpath: "c:\mongo\data", directoryperdb: true, logappend: true,
logpath: "c:\mongo\logs", service: true }
Thu Sep 29 11:51:31 [initandlisten] journal dir=c:/mongo/data/journal
Thu Sep 29 11:51:31 [initandlisten] recover : no journal files
present, no recovery needed
Thu Sep 29 11:51:32 [initandlisten] waiting for connections on port
27017
Thu Sep 29 11:51:32 [websvr] admin web console waiting for connections
on port 28017
Thu Sep 29 11:52:32 [clientcursormon] mem (MB) res:20 virt:61 mapped:0
Thu Sep 29 11:53:19 [initandlisten] connection accepted from
127.0.0.1:2005 #1
Thu Sep 29 11:53:19 [conn1] build index hhhh.dsssss { _id: 1 }
Thu Sep 29 11:53:19 [conn1] build index done 0 records 0.029 secs
Thu Sep 29 11:53:25 [conn1] build index hhhh.dsssss { dd: 1 }
Thu Sep 29 11:54:00 [conn1] external sort used : 20000 files in 34
secs

Harvester of Sorrow

unread,
Sep 29, 2011, 5:03:26 AM9/29/11
to mongodb-user
Another problem is that:

doc.Add("1", BsonInt32.Create(1));
doc.Add("2", BsonInt32.Create(1));
doc.Add("3", BsonInt32.Create(1));
doc.Add("4", BsonInt32.Create(1));
doc.Add("5", BsonInt32.Create(1));
doc.Add("6", BsonInt32.Create(1));
doc.Add("7", BsonInt32.Create(1));
doc.Add("8", BsonInt32.Create(1));
doc.Add("9", BsonInt32.Create(1));

Create no fields. No error is thrown. I guess that the name cannot
contain digits, but at least an error should be thrown :)

Harvester of Sorrow

unread,
Sep 29, 2011, 5:11:56 AM9/29/11
to mongodb-user
The mongo.exe seems to become unresponsive. I tried to use MongoVUE to
connect and get the stats (haven't stopped the service) but it gets
unresponsive also. (this is after 15 minutes).

After stopping the mongo.exe, stats for the collection shows (in
MongoVUE):

ns hhhh.dsssss
count 100
size 42923784
avbObjSize 429237.84
storageSize 51113984
numExtents 5
nindexes 1
lastExtentSize 14245888
paddingFactor 1
flags 1
totalIndexSize 8176
indexSizes
_id_ 8176
ok 1

On Sep 29, 10:15 am, "Nat" <nat.lu...@gmail.com> wrote:

Nat

unread,
Sep 29, 2011, 6:42:39 AM9/29/11
to mongod...@googlegroups.com
It sounds like the indexing is still in progress. Can you try the same with mongodb 1.8 to see how long it takes?

Harvester of Sorrow

unread,
Sep 29, 2011, 6:57:19 AM9/29/11
to mongodb-user
It seems to be no difference (with 1.8.1)

Robert Stam

unread,
Sep 29, 2011, 10:10:48 AM9/29/11
to mongodb-user
Keen in mind that when you index on an array field each individual
item in the array is indexed. So you are creating an index with 100 x
40,000, or 4,000,000 entries. This is going to take awhile...

The C# driver is simply timing out because the operation did not
complete within the default timeout. You could configure a higher
timeout value, but... it is much better to run long running operations
like this from the mongo shell, and to make sure you do it at off peak
hours. When you killed mongod.exe you aborted the creation of the
index.

If you think it is taking too long to build the index then you can
file a server bug.

Regarding your concern that the elements named "0", "1", etc... are
not being created, they look fine to me. Here's a sample document as
viewed from the shell:

> db.test.findOne()
{ "_id" : ObjectId("4e847934e447ad22c44be2ea"), "1" : 1, "2" : 1,
"3" : 1, "4" : 1, "5" : 1, "6" : 1, "7" : 1, "8" : 1,
"9" : 1, "dd" : [ 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41,

... lots of lines omitted ...

39957, 39958, 39959, 39960, 39961, 39962, 39963, 39964,
39965, 39966, 39967, 39968, 39969, 39970, 39971,
39972, 39973, 39974, 39975, 39976, 39977, 39978, 39979,
39980, 39981, 39982, 39983, 39984, 39985, 39986,
39987, 39988, 39989, 39990, 39991, 39992, 39993, 39994,
39995, 39996, 39997, 39998, 39999 ] }

Harvester of Sorrow

unread,
Sep 29, 2011, 12:22:24 PM9/29/11
to mongodb-user
Hello,

Ok. Thanks for the reply :)
Reply all
Reply to author
Forward
0 new messages