summaryrefslogtreecommitdiff
path: root/src/mongo/db/timeseries/bucket_catalog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/timeseries/bucket_catalog.cpp')
-rw-r--r--src/mongo/db/timeseries/bucket_catalog.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp
index 81c8987be40..cef4bb3a964 100644
--- a/src/mongo/db/timeseries/bucket_catalog.cpp
+++ b/src/mongo/db/timeseries/bucket_catalog.cpp
@@ -1506,24 +1506,6 @@ BucketCatalog::Bucket* BucketCatalog::_reopenBucket(Stripe* stripe,
_expireIdleBuckets(stripe, stripeLock, stats, closedBuckets);
- // If this bucket was archived, we need to remove it from the set of archived buckets.
- if (auto setIt = stripe->archivedBuckets.find(key.hash);
- setIt != stripe->archivedBuckets.end()) {
- auto& archivedSet = setIt->second;
- if (auto bucketIt = archivedSet.find(bucket->getTime());
- bucketIt != archivedSet.end() && bucket->id() == bucketIt->second.bucketId) {
- long long memory =
- _marginalMemoryUsageForArchivedBucket(bucketIt->second, archivedSet.size() == 1);
- if (archivedSet.size() == 1) {
- stripe->archivedBuckets.erase(setIt);
- } else {
- archivedSet.erase(bucketIt);
- }
- _memoryUsage.fetchAndSubtract(memory);
- _numberOfActiveBuckets.fetchAndSubtract(1);
- }
- }
-
hangTimeseriesInsertBeforeReopeningBucket.pauseWhileSet();
// We may need to initialize the bucket's state.
@@ -1544,6 +1526,24 @@ BucketCatalog::Bucket* BucketCatalog::_reopenBucket(Stripe* stripe,
return nullptr;
}
+ // If this bucket was archived, we need to remove it from the set of archived buckets.
+ if (auto setIt = stripe->archivedBuckets.find(key.hash);
+ setIt != stripe->archivedBuckets.end()) {
+ auto& archivedSet = setIt->second;
+ if (auto bucketIt = archivedSet.find(bucket->getTime());
+ bucketIt != archivedSet.end() && bucket->id() == bucketIt->second.bucketId) {
+ long long memory =
+ _marginalMemoryUsageForArchivedBucket(bucketIt->second, archivedSet.size() == 1);
+ if (archivedSet.size() == 1) {
+ stripe->archivedBuckets.erase(setIt);
+ } else {
+ archivedSet.erase(bucketIt);
+ }
+ _memoryUsage.fetchAndSubtract(memory);
+ _numberOfActiveBuckets.fetchAndSubtract(1);
+ }
+ }
+
// Pass ownership of the reopened bucket to the bucket catalog.
auto [it, inserted] = stripe->allBuckets.try_emplace(bucket->id(), std::move(bucket));
Bucket* unownedBucket = it->second.get();