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

sort by array element is incorrect under sharding environment

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.2
    • Component/s: Querying, Sharding
    • Environment:
      centos 6.3
    • ALL

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            mongodbtudou mongodbtudou
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: