[SERVER-85923] Unsets done by update aggregation pipelines show up as replacement on change streams Created: 30/Jan/24  Updated: 30/Jan/24

Status: Needs Verification
Project: Core Server
Component/s: None
Affects Version/s: 7.0.5, 6.0.13
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kartal Kaan Bozdoğan Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

db.test.insertOne({_id: 'foo'}, {'a': 0});

// Watch the change stream

const watchCursor = db.test.watch();

while (!watchCursor.isClosed()) { let next = watchCursor.tryNext(); while (next !== null)

{ printjson(next); next = watchCursor.tryNext(); }

}

// In another shell

db.test.updateOne({_id: 'foo'}, [{$unset: ['a']}]);

Participants:

 Description   

Running an update with an aggregation pipeline with an `$unset` stage results in a change stream event of `replace`, instead of `update` with the corresponding fields marked as `removedFields`


Generated at Thu Feb 08 06:58:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.