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

Can't use $setOnInsert with a shard key

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.1
    • Component/s: Sharding
    • None
    • Environment:
      Linux Ubuntu 12.10
    • ALL
    • Hide
      mongos> db.total_video_views.stats()
      {
              "sharded" : true,
              "ns" : "vizvid.total_video_views",
              "count" : 0,
              "numExtents" : 6,
              "size" : 0,
              "storageSize" : 11182080,
              "totalIndexSize" : 24528,
              "indexSizes" : {
                      "_id_" : 8176,
                      "card_1" : 8176,
                      "site_1_vid_1_ts_1" : 8176
              },
              "avgObjSize" : 0,
              "nindexes" : 3,
              "nchunks" : 1,
              "shards" : {
                      "shard0000" : {
                              "ns" : "vizvid.total_video_views",
                              "count" : 0,
                              "size" : 0,
                              "storageSize" : 11182080,
                              "numExtents" : 6,
                              "nindexes" : 3,
                              "lastExtentSize" : 8388608,
                              "paddingFactor" : 1.9940000000003262,
                              "systemFlags" : 1,
                              "userFlags" : 0,
                              "totalIndexSize" : 24528,
                              "indexSizes" : {
                                      "_id_" : 8176,
                                      "site_1_vid_1_ts_1" : 8176,
                                      "card_1" : 8176
                              },
                              "ok" : 1
                      }
              },
              "ok" : 1
      }
      mongos> db.total_video_views.count()
      0
      mongos> db.total_video_views.update({'site': 1, 'vid': 1, 'ts': 1}, {'$set': {'count': 1}, '$setOnInsert': {'card': 1}}, {upsert:true})
      Can't modify shard key's value. field: card: 1.0 collection: vizvid.total_video_views
      
      Show
      mongos> db.total_video_views.stats() { "sharded" : true , "ns" : "vizvid.total_video_views" , "count" : 0, "numExtents" : 6, "size" : 0, "storageSize" : 11182080, "totalIndexSize" : 24528, "indexSizes" : { "_id_" : 8176, "card_1" : 8176, "site_1_vid_1_ts_1" : 8176 }, "avgObjSize" : 0, "nindexes" : 3, "nchunks" : 1, "shards" : { "shard0000" : { "ns" : "vizvid.total_video_views" , "count" : 0, "size" : 0, "storageSize" : 11182080, "numExtents" : 6, "nindexes" : 3, "lastExtentSize" : 8388608, "paddingFactor" : 1.9940000000003262, "systemFlags" : 1, "userFlags" : 0, "totalIndexSize" : 24528, "indexSizes" : { "_id_" : 8176, "site_1_vid_1_ts_1" : 8176, "card_1" : 8176 }, "ok" : 1 } }, "ok" : 1 } mongos> db.total_video_views.count() 0 mongos> db.total_video_views.update({ 'site' : 1, 'vid' : 1, 'ts' : 1}, { '$set' : { 'count' : 1}, '$setOnInsert' : { 'card' : 1}}, {upsert: true }) Can 't modify shard key' s value. field: card: 1.0 collection: vizvid.total_video_views

      Having the collection empty, when trying to do an upsert using $setOnInsert on a shard key I get the following error:

      Can't modify shard key's value. field: card: 1.0 collection: vizvid.total_video_views

            Assignee:
            alerner Alberto Lerner
            Reporter:
            eka Esteban Feldman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: