In some of our time-series tests, we check the underlying buckets and expect a certain order by sorting by _id. Note that the timestamp in the _id is only precise to the second. This is typically fine, as the counter at the end of the _id will ensure the bucket order is maintained. However, consider the case where the counter overflows back to 0 across two buckets whose minimum time are within the same second. In this scenario, the second bucket will end up sorting before the first, breaking this bucket ordering assumption.
Two potential solutions are:
- Sort by control.min[timeFieldName], which maintains the original millisecond precision of the timestamps, or by control.min._id (assuming the individual documents' ids are ordered), rather than _id.
- Manually select the timestamps so that the buckets are always at least one second apart.
- is duplicated by
-
SERVER-56637 update sort order in buckets collection query in time-series tests
- Closed