-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.2
-
Component/s: None
-
Environment:Windows 2008 R2 64bit, MS Visual C# 2010. Sample code using Windows Console project
Driver is the latest official driver (1.2.0.4274)
MongoDB:
Mon Sep 19 19:25:52 [initandlisten] db version v2.0.0, pdfile version 4.5
Mon Sep 19 19:25:52 [initandlisten] git version: nogitversion
Mon Sep 19 19:25:52 [initandlisten] build info: Linux liyong-vm.letao.com 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 BOOST_LIB_VERSION=1_41
Windows 2008 R2 64bit, MS Visual C# 2010. Sample code using Windows Console project Driver is the latest official driver (1.2.0.4274) MongoDB: Mon Sep 19 19:25:52 [initandlisten] db version v2.0.0, pdfile version 4.5 Mon Sep 19 19:25:52 [initandlisten] git version: nogitversion Mon Sep 19 19:25:52 [initandlisten] build info: Linux liyong-vm.letao.com 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 BOOST_LIB_VERSION=1_41
As I'm studying MongoDB I create a smplest mongodb code as the following:
//-----------Begining-----------
var mongo = MongoServer.Create("mongodb://192.168.56.101:27017"); //My mongodb server runing on my virtual box
for (int i = 0; i < 100000; i++)
{
var tmp = new BsonDocument {
};
mongo["db"]["foo"].Insert(tmp);
}
///--------------End------------//
Simple enough, right? Things got weired when I try to get the count of db.foo, here's the output from my linux console:
- ./mongo
MongoDB shell version: 2.0.0
connecting to: test
> db.foo.count() <--- Before I ran the sample code above
0
> use db
switched to db db
> db.foo.count()
98954 <--- After
>
//-------
According to the sample code, where it is 98954 should be 100000.
I've repeated this code many times, results vary but none of them reached 100000.
To be more sure, I run the same code using WinForm instead of WinConsole project, magically every single time the result is right. The same with Website Project. So I can be certain there's nothing wrong with my mongodb server but very likely something wrong with the driver with winconsole mode under my VS C# 2010.
I also gave this code to some of my coleagues who confirmed my above findings.