summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/noPassthrough/timeseries_collStats.js15
-rw-r--r--src/mongo/db/commands/write_commands.cpp3
-rw-r--r--src/mongo/db/timeseries/bucket_catalog.cpp14
-rw-r--r--src/mongo/db/timeseries/bucket_catalog.h3
4 files changed, 19 insertions, 16 deletions
diff --git a/jstests/noPassthrough/timeseries_collStats.js b/jstests/noPassthrough/timeseries_collStats.js
index 142caafddfa..5b6621381e7 100644
--- a/jstests/noPassthrough/timeseries_collStats.js
+++ b/jstests/noPassthrough/timeseries_collStats.js
@@ -48,7 +48,6 @@ const clearCollection = function() {
expectedStats.bucketCount = 0;
expectedStats.numCompressedBuckets = 0;
- expectedStats.numUncompressedBuckets = 0;
expectedStats.numSubObjCompressionRestart = 0;
if (!initialized || !isTimeseriesScalabilityImprovementsEnabled) {
expectedStats.numBucketInserts = 0;
@@ -93,15 +92,16 @@ const checkCollStats = function(empty = false) {
// least one of those inserted buckets that we expect to have triggered an expiration
// did in fact land in a shard with an existing idle bucket that it could expire.
if (value > 33) {
- assert.gte(
- stats.timeseries[stat],
- 1,
- "Invalid 'timeseries." + stat + "' value in collStats: " + tojson(stats));
+ assert.gte(stats.timeseries[stat],
+ 1,
+ "Invalid 'timeseries." + stat +
+ "' value in collStats: " + tojson(stats.timeseries));
}
} else {
assert.eq(stats.timeseries[stat],
value,
- "Invalid 'timeseries." + stat + "' value in collStats: " + tojson(stats));
+ "Invalid 'timeseries." + stat +
+ "' value in collStats: " + tojson(stats.timeseries));
}
}
@@ -118,7 +118,8 @@ const checkCollStats = function(empty = false) {
if (expectedStats.numCompressedBuckets > 0) {
assert.lt(stats.timeseries["numBytesCompressed"],
stats.timeseries["numBytesUncompressed"],
- "Invalid 'timeseries.numBytesCompressed' value in collStats: " + tojson(stats));
+ "Invalid 'timeseries.numBytesCompressed' value in collStats: " +
+ tojson(stats.timeseries));
}
};
diff --git a/src/mongo/db/commands/write_commands.cpp b/src/mongo/db/commands/write_commands.cpp
index 1fc9d0d0519..9ef23bf54fe 100644
--- a/src/mongo/db/commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands.cpp
@@ -712,7 +712,8 @@ public:
}
// Buckets with just a single measurement is not worth compressing.
- if (closedBucket.numMeasurements <= 1) {
+ if (closedBucket.numMeasurements.has_value() &&
+ closedBucket.numMeasurements.value() <= 1) {
return {SingleWriteResult(), true};
}
diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp
index 1c91bf38d5a..7ff3a4c7414 100644
--- a/src/mongo/db/timeseries/bucket_catalog.cpp
+++ b/src/mongo/db/timeseries/bucket_catalog.cpp
@@ -1518,9 +1518,7 @@ void BucketCatalog::_archiveBucket(Stripe* stripe, WithLock stripeLock, Bucket*
auto it = archivedSet.find(bucket->getTime());
if (it == archivedSet.end()) {
archivedSet.emplace(bucket->getTime(),
- ArchivedBucket{bucket->id(),
- bucket->getTimeField().toString(),
- bucket->numMeasurements()});
+ ArchivedBucket{bucket->id(), bucket->getTimeField().toString()});
long long memory = _marginalMemoryUsageForArchivedBucket(archivedSet[bucket->getTime()],
archivedSet.size() == 1);
@@ -1661,7 +1659,7 @@ void BucketCatalog::_expireIdleBuckets(Stripe* stripe,
invariant(!archivedSet.empty());
auto& [timestamp, bucket] = *archivedSet.begin();
- ClosedBucket closed{bucket.bucketId, bucket.timeField, bucket.numMeasurements, true};
+ ClosedBucket closed{bucket.bucketId, bucket.timeField, boost::none, true};
long long memory = _marginalMemoryUsageForArchivedBucket(bucket, archivedSet.size() == 1);
_bucketStateManager.eraseBucketState(bucket.bucketId);
@@ -1832,8 +1830,12 @@ std::shared_ptr<BucketCatalog::ExecutionStats> BucketCatalog::_getExecutionStats
long long BucketCatalog::_marginalMemoryUsageForArchivedBucket(const ArchivedBucket& bucket,
bool onlyEntryForMatchingMetaHash) {
- return sizeof(std::size_t) + sizeof(Date_t) + sizeof(ArchivedBucket) + bucket.timeField.size() +
- (onlyEntryForMatchingMetaHash ? sizeof(decltype(Stripe::archivedBuckets)::value_type) : 0);
+ return sizeof(Date_t) + // key in set of archived buckets for meta hash
+ sizeof(ArchivedBucket) + // main data for archived bucket
+ bucket.timeField.size() + // allocated space for timeField string, ignoring SSO
+ (onlyEntryForMatchingMetaHash ? sizeof(std::size_t) + // key in set (meta hash)
+ sizeof(decltype(Stripe::archivedBuckets)::value_type) // set container
+ : 0);
}
class BucketCatalog::ServerStatus : public ServerStatusSection {
diff --git a/src/mongo/db/timeseries/bucket_catalog.h b/src/mongo/db/timeseries/bucket_catalog.h
index c68f101fb18..c3dc40c915d 100644
--- a/src/mongo/db/timeseries/bucket_catalog.h
+++ b/src/mongo/db/timeseries/bucket_catalog.h
@@ -138,7 +138,7 @@ public:
struct ClosedBucket {
OID bucketId;
std::string timeField;
- uint32_t numMeasurements;
+ boost::optional<uint32_t> numMeasurements;
bool eligibleForReopening = false;
};
using ClosedBuckets = std::vector<ClosedBucket>;
@@ -479,7 +479,6 @@ protected:
struct ArchivedBucket {
OID bucketId;
std::string timeField;
- uint32_t numMeasurements;
};
/**