The indexes are identical:
NID_A:
> db.NIDEntry.getIndexes();
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "NID_A.NIDEntry",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"AssociatedNumbers.SubscriberNumber" : 1,
"AssociatedNumbers.AreaCode" : 1,
"AssociatedNumbers.CountryCode" : 1
},
"unique" : true,
"ns" : "NID_A.NIDEntry",
"name" : "AssociatedNumbers.SubscriberNumber_1_AssociatedNumbers.AreaCode_1_AssociatedNumbers.CountryCode_1",
"sparse" : true
}
]
NID_P:
> db.NIDEntry.getIndexes();
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "NID_P.NIDEntry",
"name" : "_id_"
},
{
"v" : 1,
"key" : {
"AssociatedNumbers.SubscriberNumber" : 1,
"AssociatedNumbers.AreaCode" : 1,
"AssociatedNumbers.CountryCode" : 1
},
"unique" : true,
"ns" : "NID_P.NIDEntry",
"name" : "AssociatedNumbers.SubscriberNumber_1_AssociatedNumbers.AreaCode_1_AssociatedNumbers.CountryCode_1",
"sparse" : true
}
]
This is the stacktrace:
WriteConcern detected an error 'E11000 duplicate key error index: NID_P.NIDEntry.$AssociatedNumbers.SubscriberNumber_1_AssociatedNumbers.AreaCode_1_AssociatedNumbers.CountryCode_1 dup key: { : "123456", : "0987", : "0031" }'. (Response was { "err" : "E11000 duplicate key error index: NID_P.NIDEntry.$AssociatedNumbers.SubscriberNumber_1_AssociatedNumbers.AreaCode_1_AssociatedNumbers.CountryCode_1 dup key: { : \"123456\", : \"0987\", : \"0031\" }", "code" : 11000, "n" : 0, "connectionId" : 604922, "ok" : 1.0 }).
at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, WriteConcern writeConcern, String databaseName)
at MongoDB.Driver.MongoCollection.InsertBatch(Type nominalType, IEnumerable documents, MongoInsertOptions options)
at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document, MongoInsertOptions options)
at MongoDB.Driver.MongoCollection.Save(Type nominalType, Object document, MongoInsertOptions options)
at CompanyName.NIDRepository.NIDEntryRepository.Update(NIDEntry entry)
at NIDWCF.NIDWCFService.Update(NIDEntry nidentry) in d:\<fakepath>\NIDWCF\NIDWCFService.cs:line 37
Which is funny, because now I notice
.Save() calling
.Insert() which, I guess, should have been an
.Update() call?. Now, to figure out why it is determined by .Save() to call
.Insert() instead of
.Update(). Maybe
idProvider.GetDocumentId() somehow fails to retrieve the document-Id? Would you happen to know of any changes in 1.6.1 to 1.7 that would've impacted this?
I would like to do a little more debugging but because this problem only exists in the production server and this server is, d'uh, in production that kinda limits my options. I will, later today, start mongo with the
-v argument to see if I can find out more but I'm more and more convinced the problem lies in either the driver or the WCF service and/or MongoRepository; if the mongo-
server were the problem the problem would (probably) also exist using the 1.6.1 driver. Then, leaving the WCF service, MongoRepository and the driver; which one is it? The WCF service hasn't changed other than referencing the new MongoRepository; MongoRepository
hasn't changed much either (updated to v1.7 driver and using MongoClient instead of MongoServer, see
relevant diff). But, since this bug doesn't exist in D, T and A I don't know why it would fail in P. And finally: I am quite sure the driver isn't the problem either (since I highly regard R. Stam :-) ). So I'll have to do some more digging. Results will be posted as soon as I have them.
Again, thanks for thinking along with me.
Rob