[DOCS-10517] Documentation on Unique Key for Sharded Cluster wrong Created: 12/Jul/17  Updated: 30/Oct/23  Resolved: 03/Dec/18

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Major - P3
Reporter: Roy Rim Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 5 years, 10 weeks, 2 days ago

 Description   

The first sentence on unique keys for sharded clusters on this link says this:

For a sharded collection, only the _id field index and the index on the shard key or a compound index where the shard key is a prefix can be unique

This implies to me that the _id field can be unique across the cluster AND the shard key can be unique as well.

Which is wrong. Within a particular shard _id can be unique. But the only index that can be truly unique across the cluster either has to be the shard key or a index that has the shard key as a prefix. We're actually depending/hoping that the _id on its own is unique without enforcing uniqueness (i.e. ObjectID is usually reliably unique).

I would rewrite this as:

For a sharded collection, only the index on the shard key or a compound index where the shard key is a prefix can be unique.

And add a warning somewhere below that specifically states that the _id can only be unique across the sharded cluster if and only if its the shard key and that when generating _id values that ObjectID or something suitably unique should be used as well.

Roy



 Comments   
Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: tweak - bold the word not
Branch: v3.2
https://github.com/mongodb/docs/commit/b20506b9b1a6bfaa1a606686e44e488905ac5f52

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: tweak - bold the word not
Branch: v3.4
https://github.com/mongodb/docs/commit/056895e35665f113a9885bb06ed9f9ef24f3c6e0

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: tweak - bold the word not
Branch: v3.6
https://github.com/mongodb/docs/commit/6174185c5a4b2e77f77a759aa9ce1dcd7338836e

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: tweak - bold the word not
Branch: master
https://github.com/mongodb/docs/commit/c3814ac6a27b058831e979ec55d6088dcb500b02

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: tweak - bold the word not
Branch: v4.0
https://github.com/mongodb/docs/commit/eed67f2b838856659cbdc0df8b969c30aef98048

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: unique index and shard keys
Branch: v3.2
https://github.com/mongodb/docs/commit/91efa8f1a2ccb6fb0fddddc5f01ab5f2d1a0b14b

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: unique index and shard keys
Branch: v3.4
https://github.com/mongodb/docs/commit/0f0808c2df4e0f35e509193a12a85d753ab7ae78

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: unique index and shard keys
Branch: v3.6
https://github.com/mongodb/docs/commit/66135c5fbc722cb571ad834243bfb00b9cdc685c

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: unique index and shard keys
Branch: master
https://github.com/mongodb/docs/commit/cb0d75af037797c55ca681d207f8e619bfc980e6

Comment by Githook User [ 03/Dec/18 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@mongodb.com'}

Message: DOCS-10517: unique index and shard keys
Branch: v4.0
https://github.com/mongodb/docs/commit/22aa21a9e9b69404df74b4a6f40b819e966f2106

Comment by Brian Moss [ 17/Jan/18 ]

PR: https://github.com/mongodb/docs/pull/3197

Generated at Thu Feb 08 08:00:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.