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

[4.4] Update with update modifiers silently does not perform an update

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.4.6
    • Component/s: Query Execution
    • Labels:
      None
    • Query Execution
    • ALL
    • Hide

      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" : "" } }
      
      Show
      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 " : " " } }
    • 23

      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.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            mindaugas.malinauskas@mongodb.com Mindaugas Malinauskas
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: