[SERVER-79787] Ordered timeseries inserts may return wrong 'n' value when a statement fails Created: 07/Aug/23  Updated: 31/Jan/24  Resolved: 31/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 8.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Lingzhi Deng Assignee: Yuhong Zhang
Resolution: Fixed Votes: 0
Labels: storex-ranked
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-82975 Timeseries insert misreports "n" fiel... Closed
Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Operating System: ALL
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)
}

Sprint: Execution Team 2024-02-05
Participants:

 Description   

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



 Comments   
Comment by Githook User [ 30/Jan/24 ]

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

Generated at Thu Feb 08 06:41:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.