we are facing a very weird problem while on insertion query, it's working fine on local mongodb but its causing problem on MongoHQ.
When data is a little bit long in in insertion query, Rails, Mongo Id query, MongoHq return true but actually data will not be inserted, following queries are being logged in following cases.
Failure cases:
Dev-Stats['gm_metrics'].insert([
{"_id"=>BSON::ObjectId('50c01eccb4e36b0002000003'), "metric_name"=>2, "count"=>1, "parameters"=>[{"param"=>"user_id", "value"=>"4f0be09cc8c1950001000001"}, {"param"=>"created_at", "value"=>"2012-12-06 04:27:56 +0000"}, {"param"=>"game_id", "value"=>"4e8d712aa510cb0001000002"}], "updated_at"=>2012-12-06 04:27:56 UTC, "created_at"=>2012-12-06 04:27:56 UTC}
])
Our Rails Query from which above mongodb query is generated
GmMetric.with(:safe=>false).create({:metric_name=>2, :count=>1,:parameters => [{"param"=>"user_id", "value"=>"4f0be09cc8c1950001000001"},{"param"=>"created_at", :value=>"#{Time.now}"},{"param"=>"game_id", :value1=>"4e8d712aa510cb0001000002"}]})
Dev-Stats['gm_metrics'].insert([{"_id"=>BSON::ObjectId('50c01eccb4e36b0002000003'), "metric_name"=>2, "count"=>1, "parameters"=>[{"param"=>"user_id", "value"=>"123456"}, {"param"=>"created_at", "value"=>"2012-12-06 04:27:56 +0000"}, {"param"=>"game_id", "value"=>"123456"},{"param"=>"game_id", "value"=>"123456"}], "updated_at"=>2012-12-06 04:28:56 UTC, "created_at"=>2012-12-06 04:28:56 UTC}])
Success Cases
Dev-Stats['gm_metrics'].insert([{"_id"=>BSON::ObjectId('50c01eccb4e36b0002000003'), "metric_name"=>2, "count"=>1, "parameters"=>[{"param"=>"user_id", "value"=>"4f0be09cc8c1950001000001"}, {"param"=>"created_at", "value"=>"2012-12-06 04:27:56 +0000"}, {"param"=>"game_id", "value"=>"123456"}], "updated_at"=>2012-12-06 04:28:56 UTC, "created_at"=>2012-12-06 04:28:56 UTC}])
Dev-Stats['gm_metrics'].insert([{"_id"=>BSON::ObjectId('50c01eccb4e36b0002000003'), "metric_name"=>2, "count"=>1, "parameters"=>[{"param"=>"user_id", "value"=>"4f0be09cc8c1950001000001"}, {"param"=>"created_at", "value"=>"4f0be09cc8c1950001000001"}], "updated_at"=>2012-12-06 04:28:56 UTC, "created_at"=>2012-12-06 04:28:56 UTC}])
For them above cases its confirm that when query lenght is long its not being inserted into database , but when we try to insert with fewer parameters and short values , we always get success. Please guide us how to fix it.