-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.8.2, 2.0.0
-
Component/s: None
-
None
-
ALL
Shard keys are supposed to be immutable. This is enforced during update when using an update modifier like $set but not when passing an entire document:
mongos> db.runCommand({shardcollection: 'foo.things', key:
{'foobar': 1}, unique: true})
{ "collectionsharded" : "foo.things", "ok" : 1 }...
mongos> db.things.find()
mongos> db.things.update(
{'foobar': 123}, {'$set': {'foobar': 456}})
Can't modify shard key's value fieldfoobar for collection: foo.things
mongos> doc = db.things.findOne()
mongos> doc.foobar = 456
456
mongos> db.things.save(doc)
mongos> db.things.find()
See the attached js for an example using update directly (without upsert).
- is related to
-
SERVER-7379 Immutable shardkey becomes mutable
- Closed