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

Commands without optional query may target to wrong shards on mongos

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      Run attached script for count and mapReduce

      Show
      Run attached script for count and mapReduce

      Description

      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.

        Attachments

        1. sh_count.js
          1 kB
        2. sh_mr.js
          1 kB

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: