is it possible to have 2 documents having the same _id in the same collection but different shards?
Hi @Abdullah_Alfadhel ,
It is possible to have duplicate _id documents for the same collection on different shards if _id is not a prefix of the shard key.
Per the documentation on Sharded Clusters and Unique Indexes:
If the
_idfield is not the shard key or the prefix of the shard key,_idindex only enforces the uniqueness constraint per shard and not across shards.For example, consider a sharded collection (with shard key
{x: 1}) that spans two shards A and B. Because the_idkey is not part of the shard key, the collection could have a document with_idvalue1in shard A and another document with_idvalue1in shard B.If the
_idfield is not the shard key nor the prefix of the shard key, MongoDB expects applications to enforce the uniqueness of the_idvalues across the shards.
Regards,
Stennie
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.