386 — DuplicateKeyId
writeconstraint
A duplicate _id was encountered during an internal operation
What is happening?
DuplicateKeyId is an internal variant of the duplicate key error that specifically concerns _id field collisions during internal server operations. Unlike DuplicateKey (11000) which is the general unique index violation error returned to clients, DuplicateKeyId is used in internal code paths such as chunk migration, resharding, replication initial sync, or other internal document-move operations where a document with the same _id already exists at the destination.
Common causes
- Chunk migration encountering a document with the same _id on the destination shard
- Resharding operation hitting an _id collision during data cloning
- Initial sync encountering an _id conflict with a locally created document
- Orphaned documents from a prior failed migration conflicting with incoming documents
- Application-level _id generation producing duplicates under high concurrency