...
BugZero found this defect 52 days ago.
As per the description, if for an existing timeseries collection a document is inserted that contains duplicate fields, for example: db.weather.insert( { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T20:00:00.000Z"), timestamp: ISODate("2021-05-19T20:00:00.000Z"), temp: 12 }) db.weather.insert( { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T20:00:00.000Z"), temp: 12, temp: 12 }) Then, the collection stops returning correct results. Reproduced on v8.0.1
use test17; db.createCollection( "weather", { timeseries: { timeField: "timestamp", metaField: "metadata", granularity: "seconds" }, expireAfterSeconds: 86400 } ); db.weather.insertMany( [ { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-18T00:00:00.000Z"), temp: 12 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-18T04:00:00.000Z"), temp: 11 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-18T08:00:00.000Z"), temp: 11 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-18T12:00:00.000Z"), temp: 12 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-18T16:00:00.000Z"), timestamp: ISODate("2021-05-18T16:00:00.000Z"), temp: 16 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-18T20:00:00.000Z"), temp: 15 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T00:00:00.000Z"), temp: 13 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T04:00:00.000Z"), temp: 12 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T08:00:00.000Z"), temp: 11 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T12:00:00.000Z"), temp: 12 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T16:00:00.000Z"), temp: 17 }, { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T20:00:00.000Z"), temp: 12 } ] ); db.weather.find({temp:12}); // this will return 5 matching documents db.weather.countDocuments(); // this will return 12 db.weather.insert( { metadata: { sensorId: 5578, type: "temperature" }, timestamp: ISODate("2021-05-19T20:00:00.000Z"), temp: 12, temp: 12 }) db.weather.find({temp:12}); // this will now return 1 or 0 matches db.weather.countDocuments(); // this will now return 0