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

Sorting a cursor on sharded coll returns documents that are missing $-prefixed fields

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 5.0.15, 6.0.4, 6.2.0-rc0
    • Affects Version/s: 5.0.9, 6.0.0-rc10
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v6.0, v5.0
    • QO 2022-07-11, QO 2022-07-25, QO 2022-08-08, QO 2022-08-22, QO 2022-09-05, QO 2022-09-19, QO 2022-10-03, QO 2022-10-17, QO 2022-10-31

      It seems after sorting a cursor that is querying a sharded collection, the documents that the cursor returns are missing $-prefixed fields. Repro of the bug, provided by max.hirschhorn@mongodb.com:

      (function() {
      "use strict";
      
      const document = ({_id: 5, $set: {$inc: {x: 5}}});
      assert.commandWorked(db.mycoll.insert(document));
      assert.eq([document], db.mycoll.find().hint({$natural: 1}).toArray());
      assert.eq([document], db.mycoll.find().hint({_id: 1}).toArray());
      assert.eq([document], db.mycoll.find().sort({_id: 1}).toArray());
      })();
      

      will fail on the sort() call if run in the sharded_collections_jscore_passthrough suite.

      This bug happens on 5.0, 6.0, and master. We should also investigate if this applies to dot prefixed fields as well.

            Assignee:
            joel.redman@mongodb.com Joel Redman (Inactive)
            Reporter:
            xuerui.fa@mongodb.com Xuerui Fa
            Votes:
            0 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: