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

Can't use $setOnInsert with a shard key

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.4.1
    • Fix Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Environment:
      Linux Ubuntu 12.10
    • Operating System:
      ALL
    • Steps To Reproduce:
      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

      Description

      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

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: