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

Ordered timeseries inserts may return wrong 'n' value when a statement fails

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Storage Execution
    • Fully Compatible
    • ALL
    • Hide
      foo:PRIMARY> db.createCollection("coll", {timeseries: {timeField: 'time'}})
      {
              "ok" : 1,
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1691419064, 2),
                      "signature" : {
                              "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                              "keyId" : NumberLong(0)
                      }
              },
              "operationTime" : Timestamp(1691419064, 2)
      }
      foo:PRIMARY> db.runCommand({insert: "coll", documents: [{x: 0, time: ISODate()}, {x: 1}], ordered: true})
      {
              "n" : 2,
              "electionId" : ObjectId("7fffffff0000000000000004"),
              "opTime" : {
                      "ts" : Timestamp(1691419106, 1),
                      "t" : NumberLong(4)
              },
              "writeErrors" : [
                      {
                              "index" : 1,
                              "code" : 2,
                              "errmsg" : "'time' must be present and contain a valid BSON UTC datetime value"
                      }
              ],
              "ok" : 1,
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1691419106, 1),
                      "signature" : {
                              "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                              "keyId" : NumberLong(0)
                      }
              },
              "operationTime" : Timestamp(1691419106, 1)
      }
      foo:PRIMARY> db.runCommand({insert: "coll", documents: [{x: 0, time: ISODate()}, {x: 1}], ordered: false})
      {
              "n" : 1,
              "electionId" : ObjectId("7fffffff0000000000000004"),
              "opTime" : {
                      "ts" : Timestamp(1691419125, 1),
                      "t" : NumberLong(4)
              },
              "writeErrors" : [
                      {
                              "index" : 1,
                              "code" : 2,
                              "errmsg" : "'time' must be present and contain a valid BSON UTC datetime value"
                      }
              ],
              "ok" : 1,
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1691419125, 1),
                      "signature" : {
                              "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                              "keyId" : NumberLong(0)
                      }
              },
              "operationTime" : Timestamp(1691419125, 1)
      }
      
      Show
      foo:PRIMARY> db.createCollection("coll", {timeseries: {timeField: 'time'}}) { "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1691419064, 2), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1691419064, 2) } foo:PRIMARY> db.runCommand({insert: "coll", documents: [{x: 0, time: ISODate()}, {x: 1}], ordered: true}) { "n" : 2, "electionId" : ObjectId("7fffffff0000000000000004"), "opTime" : { "ts" : Timestamp(1691419106, 1), "t" : NumberLong(4) }, "writeErrors" : [ { "index" : 1, "code" : 2, "errmsg" : "'time' must be present and contain a valid BSON UTC datetime value" } ], "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1691419106, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1691419106, 1) } foo:PRIMARY> db.runCommand({insert: "coll", documents: [{x: 0, time: ISODate()}, {x: 1}], ordered: false}) { "n" : 1, "electionId" : ObjectId("7fffffff0000000000000004"), "opTime" : { "ts" : Timestamp(1691419125, 1), "t" : NumberLong(4) }, "writeErrors" : [ { "index" : 1, "code" : 2, "errmsg" : "'time' must be present and contain a valid BSON UTC datetime value" } ], "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1691419125, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1691419125, 1) }
    • Execution Team 2024-02-05

      I think this is because performOrderedTimeseriesWrites always returns the document size even when errors may present.

            Assignee:
            yuhong.zhang@mongodb.com Yuhong Zhang
            Reporter:
            lingzhi.deng@mongodb.com Lingzhi Deng
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: