|
The way we route our updates it's possible to have an update that is routed to the shard that has no documents matching the 'find' portion of the update. In this case the update operation becomes a successful no-op:
mongos> sh.status()
|
--- Sharding Status ---
|
sharding version: {
|
"_id" : 1,
|
"version" : 4,
|
"minCompatibleVersion" : 4,
|
"currentVersion" : 5,
|
"clusterId" : ObjectId("53e904dbe1c9b456f8737f94")
|
}
|
shards:
|
{ "_id" : "shard0000", "host" : "AD-MAC10G.local:27031" }
|
{ "_id" : "shard0001", "host" : "AD-MAC10G.local:27032" }
|
databases:
|
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
|
{ "_id" : "my_test_db", "partitioned" : true, "primary" : "shard0000" }
|
my_test_db.my_test_coll
|
shard key: { "a" : 1, "b" : 1 }
|
chunks:
|
shard0001 1
|
shard0000 2
|
{ "a" : { "$minKey" : 1 }, "b" : { "$minKey" : 1 } } -->> { "a" : 1, "b" : 1000 } on : shard0001 Timestamp(2, 0)
|
{ "a" : 1, "b" : 1000 } -->> { "a" : 1, "b" : 2000 } on : shard0000 Timestamp(2, 2)
|
{ "a" : 1, "b" : 2000 } -->> { "a" : { "$maxKey" : 1 }, "b" : { "$maxKey" : 1 } } on : shard0000 Timestamp(2, 3)
|
{ "_id" : "test", "partitioned" : false, "primary" : "shard0001" }
|
|
mongos> db.getSisterDB(mydb).getCollection(coll).find()
|
{ "_id" : ObjectId("53e90503c100dda4430d40fb"), "a" : 1, "b" : 1, "c" : 1, "d" : 1 }
|
mongos> db.getSisterDB(mydb).getCollection(coll).update({a:1}, {a:2, b:1, c:2, d:2})
|
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 })
|
The behavior is highly misleading, because shard keys are supposed to be immutable and any application that generates 'bad' updates is likely to have a serious bug in it and hence it must receive an error.
|