Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
None
-
None
-
None
-
Storage Execution
-
ALL
Description
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, |
...
|
}
|
Attachments
Issue Links
- duplicates
-
SERVER-79787 Ordered timeseries inserts may return wrong 'n' value when a statement fails
-
- Closed
-