[SERVER-56993] [4.4] Update with update modifiers silently does not perform an update Created: 17/May/21  Updated: 06/Dec/22  Resolved: 20/May/21

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

Type: Bug Priority: Major - P3
Reporter: Mindaugas Malinauskas Assignee: Backlog - Query Execution
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-50778 "Cannot apply $bit" when $bit update ... Closed
Problem/Incident
Assigned Teams:
Query Execution
Operating System: ALL
Steps To Reproduce:

On version 4.4 (1786a10c7278a9242566ec5647687fa95bf68f12)

// Insert a document.
> db.fuzzer.insert({  "_id" : 17720, "str" : "", "num" : null, "date" : ISODate("2019-08-16T12:27:05.102Z"), "array" : [ null ], "obj" : { "obj" : { "obj" : { "obj" : { "num" : 9.094947017729282e-13 } } } }, "lon_e" : { "lon_a" : { "int_d" : NumberLong(0) } }, "int_b" : { "10" : { "lon_e" : NumberLong(0) } }, "date_d" : { "dec_a" : [ { "dec_f.dec_c.1" : NumberDecimal("-0E-6176") }, { "dec_d" : NumberDecimal("-9.999999999999999999999999999999999E+6144") }, { "dec_b.1.dec_e" : NumberDecimal("-Infinity") } ] }, "date_f" : { "10" : ISODate("2013-09-29T10:40:00Z") }, "dec_e" : { "dec_c" : { "lon_d" : [ NumberDecimal("NaN"), NumberDecimal("0"), NumberDecimal("NaN") ] } }, "str_e" : [ ], "ts_b" : { "10" : [ Timestamp(2147483648, 2147483648) ] } })
WriteResult({ "nInserted" : 1 })
 
// Perform an update.
> db.runCommand(... {  "update" : "fuzzer",  "updates" : [ { "q" : {  }, "u" : { "$min" : {...  "lon_b.str_b" : "",...  "str_e.10" : [ { "0.str_a" : "thing" }, { "str_c.str_e.str_f" : "$str" }, { "str_f.0.str_d" : "Nakfa multi-tasking" } ],...  "str_e.2" : [ { "$toString" : { "$eq" : [ { "$toBool" : { "$exp" : 9 } }, { "$strLenBytes" : { "$toLower" : "?f" } } ] } }, "Intuitive" ],...   "date_c" : [ ISODate("2008-02-29T00:00:00Z"), ISODate("9999-12-31T00:00:00Z") ],...   "date_b.date_a.2" : ISODate("2013-09-29T10:40:00Z")...   } }, "upsert" : false, "multi" : false } ],  "ordered" : true })
{ "n" : 1, "nModified" : 1, "ok" : 1 }
 
// Fetch the resulting document.
> db.fuzzer.find({})
{ "_id" : 17720, "str" : "", "num" : null, "date" : ISODate("2019-08-16T12:27:05.102Z"), "array" : [ null ], "obj" : { "obj" : { "obj" : { "obj" : { "num" : 9.094947017729282e-13 } } } }, "lon_e" : { "lon_a" : { "int_d" : NumberLong(0) } }, "int_b" : { "10" : { "lon_e" : NumberLong(0) } }, "date_d" : { "dec_a" : [ { "dec_f.dec_c.1" : NumberDecimal("-0E-6176") }, { "dec_d" : NumberDecimal("-9.999999999999999999999999999999999E+6144") }, { "dec_b.1.dec_e" : NumberDecimal("-Infinity") } ] }, "date_f" : { "10" : ISODate("2013-09-29T10:40:00Z") }, "dec_e" : { "dec_c" : { "lon_d" : [ NumberDecimal("NaN"), NumberDecimal("0"), NumberDecimal("NaN") ] } }, "str_e" : [ null, null, null, null, null, null, null, null, null, null, [ { "0.str_a" : "thing" }, { "str_c.str_e.str_f" : "$str" }, { "str_f.0.str_d" : "Nakfa multi-tasking" } ] ], "ts_b" : { "10" : [ Timestamp(2147483648, 2147483648) ] }, "date_b" : { "date_a" : { "2" : ISODate("2013-09-29T10:40:00Z") } }, "date_c" : [ ISODate("2008-02-29T00:00:00Z"), ISODate("9999-12-31T00:00:00Z") ], "lon_b" : { "str_b" : "" } }

On 5.0 (a291fb648570312ff3974fc4a92ae5b3e3da3e23) featureFlagDotsAndDollars=false

// Insert a document.
MongoDB Enterprise > db.fuzzer.insert({  "_id" : 17720, "str" : "", "num" : null, "date" : ISODate("2019-08-16T12:27:05.102Z"), "array" : [ null ], "obj" : { "obj" : { "obj" : { "obj" : { "num" : 9.094947017729282e-13 } } } }, "lon_e" : { "lon_a" : { "int_d" : NumberLong(0) } }, "int_b" : { "10" : { "lon_e" : NumberLong(0) } }, "date_d" : { "dec_a" : [ { "dec_f.dec_c.1" : NumberDecimal("-0E-6176") }, { "dec_d" : NumberDecimal("-9.999999999999999999999999999999999E+6144") }, { "dec_b.1.dec_e" : NumberDecimal("-Infinity") } ] }, "date_f" : { "10" : ISODate("2013-09-29T10:40:00Z") }, "dec_e" : { "dec_c" : { "lon_d" : [ NumberDecimal("NaN"), NumberDecimal("0"), NumberDecimal("NaN") ] } }, "str_e" : [ ], "ts_b" : { "10" : [ Timestamp(2147483648, 2147483648) ] } })
WriteResult({ "nInserted" : 1 })
 
// Perform an update.
MongoDB Enterprise > db.runCommand(
... ... {  "update" : "fuzzer",  "updates" : [ { "q" : {  }, "u" : { "$min" : {
... ...  "lon_b.str_b" : "",
... ...  "str_e.10" : [ { "0.str_a" : "thing" }, { "str_c.str_e.str_f" : "$str" }, { "str_f.0.str_d" : "Nakfa multi-tasking" } ],
... ...  "str_e.2" : [ { "$toString" : { "$eq" : [ { "$toBool" : { "$exp" : 9 } }, { "$strLenBytes" : { "$toLower" : "?f" } } ] } }, "Intuitive" ],
... ...   "date_c" : [ ISODate("2008-02-29T00:00:00Z"), ISODate("9999-12-31T00:00:00Z") ],
... ...   "date_b.date_a.2" : ISODate("2013-09-29T10:40:00Z")
... ...   } }, "upsert" : false, "multi" : false } ],  "ordered" : true })
{
	"n" : 0,
	"writeErrors" : [
		{
			"index" : 0,
			"code" : 52,
			"errmsg" : "The dollar ($) prefixed field '$toString' in 'str_e.2.0.$toString' is not valid for storage."
		}
	],
	"nModified" : 0,
	"ok" : 1
}

On 5.0 (a291fb648570312ff3974fc4a92ae5b3e3da3e23) featureFlagDotsAndDollars=true

// Insert a document.
MongoDB Enterprise > db.fuzzer.insert({  "_id" : 17720, "str" : "", "num" : null, "date" : ISODate("2019-08-16T12:27:05.102Z"), "array" : [ null ], "obj" : { "obj" : { "obj" : { "obj" : { "num" : 9.094947017729282e-13 } } } }, "lon_e" : { "lon_a" : { "int_d" : NumberLong(0) } }, "int_b" : { "10" : { "lon_e" : NumberLong(0) } }, "date_d" : { "dec_a" : [ { "dec_f.dec_c.1" : NumberDecimal("-0E-6176") }, { "dec_d" : NumberDecimal("-9.999999999999999999999999999999999E+6144") }, { "dec_b.1.dec_e" : NumberDecimal("-Infinity") } ] }, "date_f" : { "10" : ISODate("2013-09-29T10:40:00Z") }, "dec_e" : { "dec_c" : { "lon_d" : [ NumberDecimal("NaN"), NumberDecimal("0"), NumberDecimal("NaN") ] } }, "str_e" : [ ], "ts_b" : { "10" : [ Timestamp(2147483648, 2147483648) ] } })
WriteResult({ "nInserted" : 1 })
 
// Perform an update.
MongoDB Enterprise > db.runCommand( {  "update" : "fuzzer",  "updates" : [ { "q" : {  }, "u" : { "$min" : {  "lon_b.str_b" : "",  "str_e.10" : [ { "0.str_a" : "thing" }, { "str_c.str_e.str_f" : "$str" }, { "str_f.0.str_d" : "Nakfa multi-tasking" } ],  "str_e.2" : [ { "$toString" : { "$eq" : [ { "$toBool" : { "$exp" : 9 } }, { "$strLenBytes" : { "$toLower" : "?f" } } ] } }, "Intuitive" ],   "date_c" : [ ISODate("2008-02-29T00:00:00Z"), ISODate("9999-12-31T00:00:00Z") ],   "date_b.date_a.2" : ISODate("2013-09-29T10:40:00Z")   } }, "upsert" : false, "multi" : false } ],  "ordered" : true })
{ "n" : 1, "nModified" : 1, "ok" : 1 }
 
// Fetch the resulting document.
MongoDB Enterprise > db.fuzzer.find({})
{ "_id" : 17720, "str" : "", "num" : null, "date" : ISODate("2019-08-16T12:27:05.102Z"), "array" : [ null ], "obj" : { "obj" : { "obj" : { "obj" : { "num" : 9.094947017729282e-13 } } } }, "lon_e" : { "lon_a" : { "int_d" : NumberLong(0) } }, "int_b" : { "10" : { "lon_e" : NumberLong(0) } }, "date_d" : { "dec_a" : [ { "dec_f.dec_c.1" : NumberDecimal("-0E-6176") }, { "dec_d" : NumberDecimal("-9.999999999999999999999999999999999E+6144") }, { "dec_b.1.dec_e" : NumberDecimal("-Infinity") } ] }, "date_f" : { "10" : ISODate("2013-09-29T10:40:00Z") }, "dec_e" : { "dec_c" : { "lon_d" : [ NumberDecimal("NaN"), NumberDecimal("0"), NumberDecimal("NaN") ] } }, "str_e" : [ null, null, [ { "$toString" : { "$eq" : [ { "$toBool" : { "$exp" : 9 } }, { "$strLenBytes" : { "$toLower" : "?f" } } ] } }, "Intuitive" ], null, null, null, null, null, null, null, [ { "0.str_a" : "thing" }, { "str_c.str_e.str_f" : "$str" }, { "str_f.0.str_d" : "Nakfa multi-tasking" } ] ], "ts_b" : { "10" : [ Timestamp(2147483648, 2147483648) ] }, "date_b" : { "date_a" : { "2" : ISODate("2013-09-29T10:40:00Z") } }, "date_c" : [ ISODate("2008-02-29T00:00:00Z"), ISODate("9999-12-31T00:00:00Z") ], "lon_b" : { "str_b" : "" } }

Participants:
Linked BF Score: 23

 Description   

On 4.4 an update command with update modifiers silently does not perform an update. Please see the test script in "Steps to Reproduce". Field "str_e" does not get updated. In version 5.0, the same command fails since the field to be inserted starts with character $. In version 5.0, when feature flag for https://jira.mongodb.org/browse/PM-1856, which will permit "$" prefixes in field names, the field "str_e" gets correctly updated.

I believe 4.4 version should work in the same way as 5.0 without "$" prefixes in field names enabled - that is, fail to insert.


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