[CSHARP-993] E11000 duplicate key error with concurrent inserts from multiple app domains Created: 11/Jun/14  Updated: 02/Apr/15  Resolved: 16/Jun/14

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: 1.9.1
Fix Version/s: 1.9.2

Type: Bug Priority: Major - P3
Reporter: Nizar Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Same BSON ObjectId is sometimes generated for two different documents when inserts are performed concurrently from different .NET app domains in the same process.

WriteConcern detected an error 'insertDocument :: caused by :: 11000 E11000 duplicate key error index: <colletionname>.$id dup key: { : ObjectId('538c82074141bd10741de97d') }'.

My thoughts:
The ObjectId class appears to not take application domains into account. Using pid, machine name, timestamp, & counter (local to each app domain) is apparently not enough to guarantee uniqueness. Perhaps, app domains should be part of the input.



 Comments   
Comment by Githook User [ 16/Jun/14 ]

Author:

{u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-993: Ensure unique ObjectIds across AppDomains.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/4b50d5da02051a47fcfeec7c2275ca8839dd3237

Comment by Githook User [ 16/Jun/14 ]

Author:

{u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-993: Ensure unique ObjectIds across AppDomains.
Branch: v1.x
https://github.com/mongodb/mongo-csharp-driver/commit/75977d0cc409c74c312db95fa834ece8d2f05496

Generated at Wed Feb 07 21:38:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.