[SERVER-72428] filter/$match not working on 1970-01-01 for timeseries collection Created: 29/Dec/22  Updated: 01/Mar/23  Resolved: 01/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.14, 6.0.2, 6.0.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Thomas MERLE Assignee: David Percy
Resolution: Duplicate Votes: 0
Labels: query-director-triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2022-12-29-17-15-16-618.png     PNG File image-2022-12-29-17-31-14-812.png     PNG File image-2022-12-29-17-31-40-393.png     PNG File image-2022-12-29-17-32-06-976.png     PNG File image-2022-12-29-17-33-19-851.png     PNG File image-2022-12-29-17-33-54-751.png    
Issue Links:
Depends
depends on SERVER-69952 Filtering on dates outside of the 32 ... Closed
Duplicate
duplicates SERVER-69952 Filtering on dates outside of the 32 ... Closed
Related
Assigned Teams:
Query Optimization
Operating System: ALL
Steps To Reproduce:

Filter on january first a timeseries collection on timestamp field

Sprint: QO 2023-02-06, QO 2023-02-20, QO 2023-03-06
Participants:

 Description   

When filtering a timestamp on january 1 1970 no document is returned.

Minimal reproduction collection:

Filter

 

$match:



 Comments   
Comment by David Percy [ 01/Mar/23 ]

Yes, this looks like a duplicate of SERVER-69952. I was able to reproduce Chris Kelly's example and confirm that SERVER-69952 fixes it. This was happening because a time-series optimization was incorrectly handling dates too close to 1970-01-01 (closer than one bucketMaxSpanSeconds): internally it creates a predicate like {_id: ObjectId( ... 1970 - bucketMaxSpanSeconds ... )} which is outside the range an ObjectId can represent.

Comment by Joe Kanaan [ 11/Jan/23 ]

misha.tyulenev@mongodb.com, can you please help assign this to someone please? Thanks!

Comment by Rushan Chen [ 03/Jan/23 ]

Thanks for reproducing the issues. chris.kelly@mongodb.com  The problem is the same as the one you referred to. Part of the fix went in 6.2 but another part is still to be completed (linked to by this ticket). Assigning now to the responsible team (QO). 

Comment by Chris Kelly [ 29/Dec/22 ]

I ran the following tests on 5.0.14 and 6.0.2 through the mongo shell:
 

query timeseries collection normal collection
db.test.find({ timestamp : { $gte : new Date("1970-01-01") }}) no output correct
db.test.find({ timestamp : { $gte : new Date("1970-01-01T12:00:000Z") }}) no output correct
db.test.aggregate({$match: {"timestamp": {$gte: new Date("1970-01-01")}}}) no output correct
 db.test.aggregate({$match: {"timestamp": {$gte: new Date("1970-01-01T12:00:000Z")}}}) no output correct

 

I'll pass this to the relevant team take a look. Thanks for your report!

Christopher

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