[SERVER-85766] An update with $pullAll behaves differently with timeseries vs non-timeseries collections Created: 26/Jan/24  Updated: 30/Jan/24  Resolved: 29/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Naama Bareket Assignee: Yuhong Zhang
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Query Integration
Operating System: ALL
Sprint: Execution Team 2024-02-05
Participants:

 Description   

Results are different when running the same update on a timeseries collection vs. regular collection with the same documents. Steps which reproduce are as follows:

For the control:

Insert these documents:

db.controlColl.insert({ _id: 17866, time: new Date("2019-11-29T15:21:52.056Z"),"tag": {"str": "Saint Martin intermediate", "obj": null}})

db.controlColl.insert({ _id: 19289, time: new Date("2019-01-14T09:44:22.760Z"),"tag": {"str": "California dot-com project", "obj": {_id: 19290, "array": [Infinity], "obj": {}}}})

Running this update:

db.controlColl.updateMany({}, {"$pullAll": {"tag.obj.array": [false, NumberDecimal("Infinity")]}}, {multi:true})

This gives us a writeError.

db.controlColl.find({})

{ "time" : ISODate("2019-01-14T09:44:22.760Z"), "tag" : { "obj" : { "_id" : 19290, "array" : [ Infinity ], "obj" : {  } }, "str" : "California dot-com project" }, "_id" : 19289 }

{ "time" : ISODate("2019-11-29T15:21:52.056Z"), "tag" : { "obj" : null, "str" : "Saint Martin intermediate" }, "_id" : 17866 }

When running the same update on a timeseries collection with the same documents the result is different:

db.createCollection("timeColl", {timeseries: {timeField: 'time', metaField: 'tag'}})

db.timeColl.insert({ _id: 17866, time: new Date("2019-11-29T15:21:52.056Z"),"tag": {"str": "Saint Martin intermediate", "obj": null}})

db.timeColl.insert({ _id: 19289, time: new Date("2019-01-14T09:44:22.760Z"),"tag": {"str": "California dot-com project", "obj": {_id: 19290, "array": [Infinity], "obj": {}}}})

db.timeColl.updateMany({}, {"$pullAll": {"tag.obj.array": [false, NumberDecimal("Infinity")]}}, {multi:true})

db.timecoll5.find({})

results:

{ "time" : ISODate("2019-01-14T09:44:22.760Z"), "tag" : { "obj" : { "_id" : 19290, "array" : [ ], "obj" : {  } }, "str" : "California dot-com project" }, "_id" : 19289 }

{ "time" : ISODate("2019-11-29T15:21:52.056Z"), "tag" : { "obj" : null, "str" : "Saint Martin intermediate" }, "_id" : 17866 }

We can see that for the document with "_id" : 19289, tag.obj.array in the control case is [Infinity] while in the timeseries case is an empty array [].

Calling the update on the document with "_id" : 17866 causes a write error since we are trying to traverse tag.obj.array but tag.obj is null. If we run the same test but only with the one document which causes no write errors, the results are the same in both the timeseries and control case:

{ "_id" : 19289, "time" : ISODate("2019-01-14T09:44:22.760Z"), "tag" : { "str" : "California dot-com project", "obj" : { "_id" : 19290, "array" : [ ], "obj" : {  } } } }

with tag.obj.array being the empty array [].

This implies we are treating write errors differently with updates in timeseries vs. without; It seems like we are continuing with the updates normally in timeseries even after a write error, but that for a normal collection we potentially stop the updates from occurring.

 


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