[SERVER-8830] Able to modify component of shard key Created: 02/Mar/13  Updated: 08/Mar/13  Resolved: 04/Mar/13

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.4.0-rc1
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Sridhar Nanjundeswaran Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

2.4.0-rc1 build on Windows 7


Attachments: File ShardKeyModify.js    
Issue Links:
Depends
Duplicate
duplicates SERVER-7379 Immutable shardkey becomes mutable Closed
Operating System: ALL
Steps To Reproduce:

mongo ShardKeyModify.js

Participants:

 Description   

The test below fails with
assert: [null] != [null] are equal : undefined
Error: Printing Stack Trace
at printStackTrace (src/mongo/shell/utils.js:37:7)
at doassert (src/mongo/shell/assert.js:6:1)
at Function.assert.neq (src/mongo/shell/assert.js:44:1)
at c:\Users\sridhar\Desktop\ShardKeyModify.js:54:8

Expect the document to be unchanged
{ "_id" : -1, "ckey" :

{ "key1" : -1, "key2" : -1 }

, "val" : -1 }
Instead the update goes through resulting in
{ "_id" : -1, "ckey" :

{ "key1" : -1, "key2" : -101 }

, "val" : -101 }

Similarly the following change should not go through
coll2Sh.update({ckey:{key1:-2, key2:-2}},{$set:{'ckey.key2':-100, val:-100}})
So instead of the document remaining unchanged as
{ "_id" : -2, "ckey" :

{ "key1" : -2, "key2" : -2 }

, "val" : -2 }
it is updated to
{ "_id" : -2, "ckey" :

{ "key1" : -2, "key2" : -100 }

, "val" : -100 }

But as expected the following results in an error
coll2Sh.update({ckey:{key1:-3, key2:-3}},{$set:{ckey:

{key1:-300,key2:-300}

, val:-100}})
Can't modify shard key's value. field: ckey:

{ key1: -300.0, key2: -300.0 }

collection: _unknown_name_.coll2Sharded


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