Info
I think this is because performOrderedTimeseriesWrites always returns the document size even when errors may present.
Top User Comments
xgen-internal-githook commented on Tue, 30 Jan 2024 22:17:33 +0000:
Author:
{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}
Message: SERVER-79787 Set the number of inserted documents correctly when write errors occur during time-series ordered inserts (#18506)
GitOrigin-RevId: 78f569b565d59144da819937a2fc7a53dffdf69a
Branch: master
https://github.com/mongodb/mongo/commit/a40bb6d649cca4b43f25ab13887658e3484ef733
Steps to Reproduce
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)
}