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

Update does not give an error message when $setOnInsert fails on FCV 3.6

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.7, 3.5.12
    • Component/s: None
    • None
    • Query
    • Fully Compatible
    • ALL
    • Hide

      FCV 3.6:

      > db.fuzzer.insert({'a': 1 })
      WriteResult({ "nInserted" : 1 })
      > db.fuzzer.update({}, {$setOnInsert: {'a.b': 2 }})
      WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })
      
      Show
      FCV 3.6: > db.fuzzer.insert({'a': 1 }) WriteResult({ "nInserted" : 1 }) > db.fuzzer.update({}, {$setOnInsert: {'a.b': 2 }}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })

      After setting FCV to 3.6 on 3.5.12, the mongo shell session appears as from the repro. This is different from FCV 3.4, which would give the following response:

      WriteResult({
      	"nMatched" : 0,
      	"nUpserted" : 0,
      	"nModified" : 0,
      	"writeError" : {
      		"code" : 16837,
      		"errmsg" : "cannot use the part (a of a.b) to traverse the element ({a: 1.0})"
      	}
      })
      

      In the example, field 'a' can actually be nearly any data type including a number, a string, an array, NaN, null, or undefined. This difference can also be observed regardless of whether multi or upsert is set to true / false. FCV 3.6 would return nMatched as the number of documents matching the <find> portion of the query.

      The WriteResult given in FCV 3.6 may not accurately reflect a reason (or reflect a reason at all) for why no documents were upserted / modified, especially when upsert is set to true.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            kimberly.hou Kimberly Hou
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: