Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14854

Updates that modify the shard key might not produce errors

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.3
    • Sharding
    • None
    • ALL
    • Sharding 2019-06-03

    Description

      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.

      Attachments

        Activity

          People

            janna.golden@mongodb.com Janna Golden
            alex.komyagin@mongodb.com Alexander Komyagin
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: