[SERVER-66469] Filtering timeseries with date-field does not include results from before 1970 Created: 15/May/22 Updated: 29/Oct/23 Resolved: 27/Sep/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 5.0.7 |
| Fix Version/s: | 6.2.0-rc0, 6.0.5, 5.0.16 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Stefan de Jong | Assignee: | Joel Redman (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | time-series | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||
| Backport Requested: |
v6.0, v5.0
|
||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: |
If you query with { $timeField: { $lt: "arbitrary date < 1970" }}, the documents missing from the previous set will suddenly show up. |
||||||||||||||||||||||||||||||||||||||||
| Sprint: | QO 2022-09-19, QO 2022-10-03 | ||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||
| Description |
|
| Comments |
| Comment by Githook User [ 15/Mar/23 ] | ||||||||
|
Author: {'name': 'Joel Redman', 'email': 'joel.redman@mongodb.com', 'username': 'joredman'}Message: (cherry picked from commit aedaf14d6dcc60253f3944252eb5cfc588e08ecb) | ||||||||
| Comment by Githook User [ 21/Feb/23 ] | ||||||||
|
Author: {'name': 'Joel Redman', 'email': 'joel.redman@mongodb.com', 'username': 'joredman'}Message: (cherry picked from commit 2b65016588fc5f868b0e396b64d1fe9da916a343) Also includes some changes from aedaf14d6dcc60253f3944252eb5cfc588e08ecb: | ||||||||
| Comment by Githook User [ 31/Jan/23 ] | ||||||||
|
Author: {'name': 'Joel Redman', 'email': 'joel.redman@mongodb.com', 'username': 'joredman'}Message: | ||||||||
| Comment by Githook User [ 27/Sep/22 ] | ||||||||
|
Author: {'name': 'Joel Redman', 'email': 'joel.redman@mongodb.com', 'username': 'joredman'}Message: | ||||||||
| Comment by Joel Redman (Inactive) [ 23/Sep/22 ] | ||||||||
|
| ||||||||
| Comment by Chris Kelly [ 24/May/22 ] | ||||||||
|
Hi Stefan, I was able to reproduce this behavior in MongoDB 5.0.7 by referencing the example time series collection and data shown here. I modified this data to add your dates. If I insert the two dates you mention (one in 1970, and one in 1965) and attempt to run:
By incrementing the date by 1 month, I will only get 1 document. If the date is equal to the one inserted, the return value is 0. If I do this again for the older date, the same phenomenon occurs: if it's equal, it returns zero. If it's slightly above, it returns 1.
The first query I list should be returning 2 in this case, since there are 2 documents with a date before 1970-02-01T18:31:22.000+00:00. You would expect this to work since it is internally represented as a signed 64-bit integer representing the number of milliseconds since the Unix epoch (Jan 1, 1970). While the docs mention that not all database operations support the full 64-bit range, it says: "you may safely work with dates with years within the inclusive range 0 through 9999." Given this information, I'm going to forward this to Query Execution for further investigation. Thank you for your report. Regards, |