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

Timeseries insert misreports "n" field when errors are present

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

      Create a timeseries collection:

      > db.runCommand({create: "myts", timeseries: {timeField: "t", metaField: "sensor"}})
      {
      	"ok" : 1,
      	...
      }
      

      Try to insert an invalid doc to it. Notice that {"n" : 1}, though nothing was inserted.

      > db.runCommand({insert: "myts", documents: [{"metadata": { "sensor": 2},  "u": ISODate("2021-05-18T00:00:00.000Z"), "temp": 12}]})
      {
      	"n" : 1,
      	"writeErrors" : [
      		{
      			"index" : 0,
      			"code" : 2,
      			"errmsg" : "'t' must be present and contain a valid BSON UTC datetime value"
      		}
      	],
      	"ok" : 1,
      	...
      }
      
      > db.myts.find().itcount()
      0
      

      For a non-timeseries collection, on a write error (say DuplicateKeyError) the correct n is returned:

      > db.runCommand({insert: "basic4", documents: [{_id: 1}]})
      {
      	"n" : 0,
      	...
      	"writeErrors" : [
      		{
      			"index" : 0,
      			"code" : 11000,
      			"errmsg" : "E11000 duplicate key error collection: test.basic4 index: _id_ dup key: { _id: 1.0 } found value: RecordId(3)",
      			"keyPattern" : {
      				"_id" : 1
      			},
      			"keyValue" : {
      				"_id" : 1
      			},
      			"foundValue" : NumberLong(3),
      			"duplicateRid" : NumberLong(3)
      		}
      	],
      	"ok" : 1,
              ...
      }
      

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            vishnu.kaushik@mongodb.com Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: