summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2021-11-01 19:20:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-02 15:04:18 +0000
commitbb2475deaf971065c2d29a1930fac9a8164a9cf0 (patch)
tree314c2eb288ab362a4051dba6a9f3a15041b806f7 /src
parent36a5fe52e2b76c6122e906237d8fb3378e4194e6 (diff)
downloadmongo-bb2475deaf971065c2d29a1930fac9a8164a9cf0.tar.gz
SERVER-59925 Stress test time-series inserts
(cherry picked from commit cf80c11bc5308d9b889ed61c1a3eeb821839df56)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/timeseries/bucket_catalog.cpp13
-rw-r--r--src/mongo/db/timeseries/bucket_catalog.h3
-rw-r--r--src/mongo/db/timeseries/timeseries.idl4
3 files changed, 15 insertions, 5 deletions
diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp
index c6fecf6f47b..978ce5037d6 100644
--- a/src/mongo/db/timeseries/bucket_catalog.cpp
+++ b/src/mongo/db/timeseries/bucket_catalog.cpp
@@ -593,16 +593,25 @@ void BucketCatalog::_verifyBucketIsUnused(Bucket* bucket) const {
void BucketCatalog::_expireIdleBuckets(ExecutionStats* stats,
std::vector<BucketCatalog::ClosedBucket>* closedBuckets) {
// Must hold an exclusive lock on _bucketMutex from outside.
- stdx::lock_guard lk{_idleMutex};
+ stdx::unique_lock lk{_idleMutex};
// As long as we still need space and have entries and remaining attempts, close idle buckets.
int32_t numClosed = 0;
while (!_idleBuckets.empty() &&
_memoryUsage.load() >
- static_cast<std::uint64_t>(gTimeseriesIdleBucketExpiryMemoryUsageThreshold) &&
+ static_cast<std::uint64_t>(gTimeseriesIdleBucketExpiryMemoryUsageThreshold.load()) &&
numClosed <= gTimeseriesIdleBucketExpiryMaxCountPerAttempt) {
Bucket* bucket = _idleBuckets.back();
+
+ lk.unlock();
_verifyBucketIsUnused(bucket);
+ lk.lock();
+ if (!bucket->_idleListEntry) {
+ // The bucket may have become non-idle between when we unlocked _idleMutex and locked
+ // the bucket's mutex.
+ continue;
+ }
+
ClosedBucket closed{
bucket->id(), bucket->getTimeField().toString(), bucket->numMeasurements()};
if (_removeBucket(bucket, true /* expiringBuckets */)) {
diff --git a/src/mongo/db/timeseries/bucket_catalog.h b/src/mongo/db/timeseries/bucket_catalog.h
index 9936a9be4c3..663f8b2b7df 100644
--- a/src/mongo/db/timeseries/bucket_catalog.h
+++ b/src/mongo/db/timeseries/bucket_catalog.h
@@ -400,7 +400,8 @@ public:
const std::shared_ptr<ExecutionStats>& stats);
// Access to the bucket is controlled by this lock
- mutable Mutex _mutex;
+ mutable Mutex _mutex =
+ MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(2), "BucketCatalog::Bucket::_mutex");
// The bucket ID for the underlying document
OID _id = OID::gen();
diff --git a/src/mongo/db/timeseries/timeseries.idl b/src/mongo/db/timeseries/timeseries.idl
index ba01d4e7121..718a6a3b791 100644
--- a/src/mongo/db/timeseries/timeseries.idl
+++ b/src/mongo/db/timeseries/timeseries.idl
@@ -49,8 +49,8 @@ server_parameters:
"timeseriesIdleBucketExpiryMemoryUsageThreshold":
description: "The threshold for bucket catalog memory usage above which idle buckets will be
expired"
- set_at: [ startup ]
- cpp_vartype: "std::int32_t"
+ set_at: [ startup, runtime ]
+ cpp_vartype: "AtomicWord<std::int32_t>"
cpp_varname: "gTimeseriesIdleBucketExpiryMemoryUsageThreshold"
default: 104857600 # 100MB
validator: { gte: 1 }