summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Larkin-York <dan.larkin-york@mongodb.com>2022-06-14 15:55:45 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-14 16:18:51 +0000
commitf275c61e5dc9cfd69be9099acbfc1b0553cd76bb (patch)
tree3484f8e127bffcb7020a8965b28bd2f94914af5c /src
parentb56ef4dbd8adc83a72e5e5c0f61b377ee954cea1 (diff)
downloadmongo-f275c61e5dc9cfd69be9099acbfc1b0553cd76bb.tar.gz
SERVER-66727 Use full-precision timestamp for time-series bucketing decision
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/timeseries/bucket_catalog.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp
index 5090e358141..10e0e2df903 100644
--- a/src/mongo/db/timeseries/bucket_catalog.cpp
+++ b/src/mongo/db/timeseries/bucket_catalog.cpp
@@ -164,7 +164,7 @@ std::pair<OID, Date_t> generateBucketId(const Date_t& time, const TimeseriesOpti
// together into predictable chunks for sharding. This way we know from a measurement timestamp
// what the bucket timestamp will be, so we can route measurements to the right shard chunk.
auto roundedTime = timeseries::roundTimestampToGranularity(time, options.getGranularity());
- uint64_t const roundedSeconds = durationCount<Seconds>(roundedTime.toDurationSinceEpoch());
+ int64_t const roundedSeconds = durationCount<Seconds>(roundedTime.toDurationSinceEpoch());
bucketId.setTimestamp(roundedSeconds);
// Now, if we stopped here we could end up with bucket OID collisions. Consider the case where
@@ -292,7 +292,7 @@ public:
// Returns the time associated with the bucket (id)
Date_t getTime() const {
- return _id.asDateT();
+ return _minTime;
}
/**
@@ -423,6 +423,9 @@ private:
// Time field for the measurements that have been inserted into the bucket.
std::string _timeField;
+ // Minimum timestamp over contained measurements
+ Date_t _minTime;
+
// The minimum and maximum values for each field in the bucket.
timeseries::MinMax _minmax;
@@ -1173,6 +1176,7 @@ BucketCatalog::Bucket* BucketCatalog::_allocateBucket(Stripe* stripe,
}
bucket->_timeField = info.options.getTimeField().toString();
+ bucket->_minTime = roundedTime;
// Make sure we set the control.min time field to match the rounded _id timestamp.
auto controlDoc = buildControlMinTimestampDoc(info.options.getTimeField(), roundedTime);