$or within findAndModify with a mongos should correctly check if all expressions in one shard

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.2.2
    • Component/s: Querying, Sharding
    • None
    • Query
    • ALL
    • Hide

      This fails
      db.responses.update({
      "$or":[

      {"itemId":24, "importDocumentId" : "90016201230095201111"}

      ,

      {"itemId":24, "importDocumentId" : "90016201230085201111"}

      ]},
      {$set:{responseStateCode:2}});
      can't do non-multi update with query that doesn't have a valid shard key

      This works
      db.responses.update({
      "itemId":{$in:[24,25]},
      "importDocumentId":{$in:["90016201230095201111", "90016201230085201111"]}},
      {$set:{responseStateCode:2}});

      -------------FindAndModify--------------

      This fails
      db.responses.findAndModify({
      query:{"$or":[

      {"itemId":24, "importDocumentId" : "90016201230095201111"}

      ,

      {"itemId":24, "importDocumentId" : "90016201230085201111"}

      ]},
      update : {$set:

      {responseStateCode:2}

      }});
      Thu Dec 13 16:12:32 uncaught exception: findAndModifyFailed failed: "db assertion failure"

      This works
      db.responses.findAndModify({
      query:{
      "itemId":{$in:[24,25]},
      "importDocumentId":{$in:["90016201230095201111", "90016201230085201111"]}},
      update : {$set:

      {responseStateCode:2}

      }});

      Show
      This fails db.responses.update({ "$or":[ {"itemId":24, "importDocumentId" : "90016201230095201111"} , {"itemId":24, "importDocumentId" : "90016201230085201111"} ]}, {$set:{responseStateCode:2}}); can't do non-multi update with query that doesn't have a valid shard key This works db.responses.update({ "itemId":{$in: [24,25] }, "importDocumentId":{$in: ["90016201230095201111", "90016201230085201111"] }}, {$set:{responseStateCode:2}}); ------------- FindAndModify -------------- This fails db.responses.findAndModify({ query:{"$or":[ {"itemId":24, "importDocumentId" : "90016201230095201111"} , {"itemId":24, "importDocumentId" : "90016201230085201111"} ]}, update : {$set: {responseStateCode:2} }}); Thu Dec 13 16:12:32 uncaught exception: findAndModifyFailed failed: "db assertion failure" This works db.responses.findAndModify({ query:{ "itemId":{$in: [24,25] }, "importDocumentId":{$in: ["90016201230095201111", "90016201230085201111"] }}, update : {$set: {responseStateCode:2} }});
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Currently doing an $or([

      {key1: A1,key2: B1}

      ,

      {key1:A2,key2:B2}

      ,...] fails in a sharded cluster because it does not first check if the values given are on the same shard, whereas $in does check. They should be consistent and do the best to implement findAndModify within one shard. The below steps to reproduce shows the differences.

            Assignee:
            Backlog - Query Team (Inactive)
            Reporter:
            Matt Kalan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: