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

Commands without optional query may target to wrong shards on mongos

    • Fully Compatible
    • ALL
    • Hide

      Run attached script for count and mapReduce

      Show
      Run attached script for count and mapReduce

      On mongos, for commands allowing optional query, e.g. count, mapreduce, if the optional query is not given, the command will use the command BSONObj itself as the query to target shards, which could return wrong shards if the shard key happens to be one of the field in the command object.

      This is because if the optional query is not given, commands call Strategy::commandOp with an empty targetingQuery parameter. The targetingQuery parameter is passed to ParallelSortClusteredCursor as CommandInfo.cmdFilter. An empty cmdFilter will be interpreted as using the command/query as a whole to target shards.

        1. sh_count.js
          1 kB
          Siyuan Zhou
        2. sh_mr.js
          1 kB
          Siyuan Zhou

            Assignee:
            siyuan.zhou@mongodb.com Siyuan Zhou
            Reporter:
            siyuan.zhou@mongodb.com Siyuan Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: