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

update $push should correctly recognize a no-op $sort

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • Labels:
    • Query Execution

      When update does a simple $push we write a $set to single array element to the oplog.
      Same when there is a $slice with it that's a "no-op"
      However, when there is a $sort that's a no-op we do not detect that.

      // updates
      db.test.update({},{$push:{a:{$each:[11]}}})
      db.test.update({},{$push:{a:{$each:[12],$slice:100}}})
      db.test.update({},{$push:{a:{$each:[13],$slice:100,$sort:1}}})
      // oplog entries (just the "o" field
      { "o" : { "$v" : 1, "$set" : { "a.6" : 11 } } }
      { "o" : { "$v" : 1, "$set" : { "a.7" : 12 } } }
      { "o" : { "$v" : 1, "$set" : { "a" : [ 0, 1, 2, 4, 5, 10, 11, 12, 13 ] } } }
      

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: