We had an application that wouldn't start because of dup key errors.
We had 5 of them, and only 3 are needed at any time.
I usually would wait an hour, and then the dup key errors would go away.
Well, this time, I shut down the application and executed a query to free the records is was working on.
Then I got this weird error message
mongos> db.JQ.update( {host: "c01"}, { $set : { inprogress : false } } ,false, true );
E11000 duplicate key error index: CUP.UPI.$_id_ dup key: { : "78b8abe8-bbe7-44d7-9b75-e22040e56e26" }
This same id was in the error message of the application.
The application ensures indexes when it starts.
Exception in thread "main" com.mongodb.MongoException$DuplicateKey: E11000 duplicate key error index: CUP.UPI.$_id_ dup key: { : "78b8abe8-bbe7-44d7-9b75-e22040e56e26" }
at com.mongodb.CommandResult.getException(CommandResult.java:80)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:116)
at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:126)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:148)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:132)
at com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:262)
at com.mongodb.DBApiLayer$MyCollection.createIndex(DBApiLayer.java:354)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:444)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:421)
CUP.UPI is a sharded collection, while JQ is not.
This didn't make any sense why one collection would block another unless mongos detected a general error and wouldn't let other things happen -- for the manual update query I ran.
What is weird, is a few minutes later, the update command worked --- as if the mongos information got updated and cleared out the problem.
The reason why I think it might be a mongos problem (somehow) is because all I have to do is wait a few minutes when my application doesn't start before the problem goes away.
We are using 2.0.6.