I was pretty much convinced that Mongo db is not the best choice for an application. But a recent incident makes me believe that it is a silent killerof the application. As you work with it and increase the amount of data/ concurrency you realize its one or more pain points.
Our application was working fine, and one fine day one of the bugs got reported signup is not working as expected. It was creating user but could not login them. The app was not updated from quite some time, no changes to the schema how could this happen. So then we searched for logs, and it was sparkling clean !!! But still no user creation and other db operations, for some reason. After some debugging we realized that saves are getting called but data is not available in mongo after the operations and surprisingly it does not throw errors. WTF !!!
Googling around how to debug mongo, leads you to some thing called WriteConcern. It is related to how mongo operations are handled. According to the documentation of MongoTemplate the default WriteConcern does not report back errors. We changed that so safe, which means it will complete that operation and report back errors if any.
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"></pre> <em id="__mceDel"><constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /></em> <em id="__mceDel"> <property name="writeConcern"> <util:constant static-field="com.mongodb.WriteConcern.SAFE"></util:constant> </property> </bean></em> <pre>
After we enabled this we got a pretty interesting error while performing save:
“com.mongodb.MongoException: can’t map file memory – mongo requires 64 bit build for larger datasets”
If you google around this, then you realize that on 32-bit machines mongo can only have 2GB of data. Now this is crap !!!
Just 2GB really ???? If you are supposed to be working with just 2GB why use a database ?? DBs are meant as data warehouses.
The only solution is left is to upgrade it to 64 bit ver. Going by my previous experiences with mongo I knew that will not be as easy as it sounds. So I cleared some old data and the application was back online.
Mongo is a great product and has good deal of features. But I am sorry to say that it is not a 100 % finished product. Increasingly you see its pain areas when you put in load and production.