[SERVER-47021] update $push should correctly recognize a no-op $sort Created: 20/Mar/20  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 1
Labels: qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 Description   

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 ] } } }



 Comments   
Comment by Asya Kamsky [ 20/Mar/20 ]

Obviously the initial array was "a" : [ 0, 1, 2, 4, 5, 10]

Generated at Thu Feb 08 05:13:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.