[SERVER-6490] Inserting array values for shard key succeeds when shard key is _id and inserts garbage data Created: 17/Jul/12  Updated: 11/Jul/16  Resolved: 26/Nov/12

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.0.6, 2.1.2
Fix Version/s: 2.3.2

Type: Bug Priority: Major - P3
Reporter: Spencer Brody (Inactive) Assignee: Kevin Matulef
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

mongo
MongoDB shell version: 2.0.4
connecting to: test
test[14:7:40]> sh.shardCollection('test.bar', {i:1})
test[14:7:53]> db.bar.insert({i : [1, 2]})
tried to insert object with no valid shard key for { i: 1.0 } : { _id: ObjectId('5005aa08ba72dc4f64314847'), i: [ 1.0, 2.0 ] }
test[14:8:9]> sh.shardCollection('test.baz', {_id:1})
test[14:8:25]> db.baz.insert({_id : [1, 2]})
test[14:8:34]> db.baz.find()
{ "_id" : ObjectId("5005aa223af26b5b5e49a1be"), "_id" : ObjectId("5005aa223af26b5b5e49a1be") }



 Comments   
Comment by auto [ 26/Nov/12 ]

Author:

{u'date': u'2012-11-26T18:10:17Z', u'email': u'matulef@gmail.com', u'name': u'Kevin Matulef'}

Message: SERVER-6490 fix bug with _id array vals.

When sharding on _id, we were not properly invalidating docs that had
an array value for the shard key. Instead we were trying to add an _id
field, even though the doc already had one.
Branch: master
https://github.com/mongodb/mongo/commit/22de9cb08d762acac32d7ac6ad476ae8a2a06eef

Generated at Thu Feb 08 03:11:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.