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

Failed to update an object with null value in shard key

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.6.0
    • Component/s: Sharding
    • None
    • ALL

      // There are 2 documents in collection virus already.
      > db.virus.find()

      { "_id" : ObjectId("4c6cf85f1dc3e52659865ff2"), "did" : 1, "recv_time" : 1, "n" : 1 } { "_id" : ObjectId("4c6cf86f1dc3e52659865ff3"), "did" : 1, "recv_time" : 2, "n" : 2 }

      // Using shard key and operator in criteria, and using modifier $set in objNew
      > db.virus.update({did:1,recv_time:{$gte:3}},{$set:{n:3}},true,false)

      // document inserted even recv_time is null
      > db.virus.find()

      { "_id" : ObjectId("4c6cf85f1dc3e52659865ff2"), "did" : 1, "recv_time" : 1, "n" : 1 } { "_id" : ObjectId("4c6cf86f1dc3e52659865ff3"), "did" : 1, "recv_time" : 2, "n" : 2 } { "_id" : ObjectId("4c6cf8f55d602a71c933a105"), "did" : 1, "n" : 3 }

      // could query with recv_time==null
      > db.virus.find(

      {recv_time:null}

      )

      { "_id" : ObjectId("4c6cf8f55d602a71c933a105"), "did" : 1, "n" : 3 }

      // Can't update via ObjectId
      > db.virus.update({_id:ObjectId("4c6cf8f55d602a71c933a105")},

      {n:4}

      )
      right object doesn't have full shard key

      // Can't update by criteria with shard key
      > db.virus.update(

      {did:1,recv_time:null}

      ,

      {n:4}

      )
      shard key must be in update object

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            stewwu Che-Ching Wu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: