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

sort by array element is incorrect under sharding environment

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: Querying, Sharding
    • Labels:
    • Environment:
      centos 6.3

      Description

      the document is like the following:

      {A:1, B:[{C:1, D:1}]}
      {A:1, B:[{C:5, D:2}]}

      my sort command is like:

      db.xxx.find().sort({B.C:1})

      it works well under single server mode, but the result may not be properly sorted under shard environment.

      it seems the mongos only fetchs data from one sharded node serially, for exmpale:
      shard1:

      {A:1, B:[{C:4, D:1}]}
      {A:1, B:[{C:5, D:2}]}

      shard2:

      {A:1, B:[{C:1, D:1}]}
      {A:1, B:[{C:2, D:2}]}

      after db.xxx.find().sort({B.C:1}), it returns like:

      {A:1, B:[{C:4, D:1}]}
      {A:1, B:[{C:5, D:2}]}
      {A:1, B:[{C:1, D:1}]}
      {A:1, B:[{C:2, D:2}]}

      I'm not sure if it's the similar bug of https://jira.mongodb.org/browse/SERVER-6118, since it's on array element while 6118 is on non-array element.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: