[SERVER-14128] Creating _id index with unique:false should result in error Created: 02/Jun/14 Updated: 11/Jul/16 Resolved: 15/Aug/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | 2.4.10, 2.6.1 |
| Fix Version/s: | 2.7.5 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Avi Levy | Assignee: | J Rassi |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Steps To Reproduce: | // Create a on unique index use foo ) ) ) ) // now the same thing, only the index is not on the id use foo ) , {unique:false}) ) ) // now the same thing without an index use foo ) ) ) |
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
When creating an index on an the _id with unique:false, the uniqueness is still enforced on it. |
| Comments |
| Comment by Githook User [ 15/Aug/14 ] |
|
Author: {u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}Message: |
| Comment by J Rassi [ 05/Jun/14 ] |
|
levyavi: only non-compound indexes on _id have the property of forced uniqueness. |
| Comment by Avi Levy [ 05/Jun/14 ] |
|
Just notice that When doing db.createCollection("bar", {capped: false, autoIndexId: false} ) no index is created. ) |
| Comment by J Rassi [ 02/Jun/14 ] |
|
Updating title to "Creating _id index with unique:false should result in error". Assigning to hari.khalsa@10gen.com for triage. |
| Comment by Andy Schwerin [ 02/Jun/14 ] |
|
levyavi, replication depends on the uniqueness of the _id field, so I'm inclined to consider this a reporting bug. That is, the server should probably have returned an error to you when you attempted to create a non-unique index of _id. Having collections without unique indexes on _id is extremely risky outside the local database, both for correctness and performance of replication. |