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

Immutable shardkey becomes mutable

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.5.3
    • Affects Version/s: 2.2.0
    • Component/s: Sharding, Write Ops
    • Labels:
      None
    • Environment:
      linux 64 bit
    • Linux

      I'm using the following shard key

      {"categoryId":1, "store":1, "_id":1}

      For testing purposes I only have one document in the collection:

      mongos> db.offerChange.find()
      { "_id" : 123, "categoryId" : 9881, "store" : "NEW" }
      

      When I want to update a field, I get correctly an alert "Can't modify shard key's value":

      mongos> db.offerChange.update({"_id":123}, {$set:{"store":"NEWEST"}}, true, false)
      Can't modify shard key's value. field: store: "NEWEST" collection: offerChange.offerChange
      

      However, I can modify the shard key by executing this:

      mongos> db.offerChange.update({"_id":123}, {"_id":123, "categoryId":9881,"store":"NEWEST"}, true, false)
      mongos> db.offerChange.find()
      { "_id" : 123, "categoryId" : 9881, "store" : "NEWEST" }
      mongos> 
      

      Also, I could call save to change the shard key again (back):

      mongos> db.offerChange.save({"categoryId":9881, "store":"NEW","_id":123})
      mongos> db.offerChange.find()
      { "_id" : 123, "categoryId" : 9881, "store" : "NEW" }
      mongos> 
      

      Now, when I try to add a second shard key field to the query, I get the same but differently expressed correct alert:

      mongos> db.offerChange.update({"_id":123,"store":"NEW"}, {"_id":123, "categoryId":9881,"store":"NEWEST"}, true, false)
      cannot modify shard key for collection offerChange.offerChange, found new value for store
      

      However, when I replace the second by the third shard key field in the query, the update works again:

      mongos> db.offerChange.update({"_id":123,"categoryId":9881}, {"_id":123, "categoryId":9881,"store":"NEWEST"}, true, false)
      mongos> db.offerChange.find()
      { "_id" : 123, "categoryId" : 9881, "store" : "NEWEST" }
      

      I asked already in the mongoDB forum but nobody answered so far.
      https://groups.google.com/group/mongodb-user/browse_thread/thread/300e0ff4676cb30b?hl=de&noredirect=true&pli=1

      As I think that's rather a bug than a feature, I opened this bug report.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            kay.agahd@idealo.de Kay Agahd
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: