summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp13
-rw-r--r--src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp7
-rw-r--r--src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h10
-rw-r--r--src/mongo/db/timeseries/bucket_catalog/execution_stats.cpp8
-rw-r--r--src/mongo/db/timeseries/bucket_catalog/execution_stats.h2
5 files changed, 39 insertions, 1 deletions
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index bf91f342d01..1b1b138fbc3 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -2906,10 +2906,21 @@ std::vector<size_t> performUnorderedTimeseriesWrites(
bool canContinue = true;
std::vector<size_t> docsToRetry;
+ stdx::unordered_set<timeseries::bucket_catalog::WriteBatch*> handledHere;
+ int64_t handledElsewhere = 0;
+ auto guard = ScopeGuard([&handledElsewhere, &request, opCtx]() {
+ if (handledElsewhere > 0) {
+ auto& bucketCatalog = timeseries::bucket_catalog::BucketCatalog::get(opCtx);
+ timeseries::bucket_catalog::reportMeasurementsGroupCommitted(
+ bucketCatalog, request.getNamespace(), handledElsewhere);
+ }
+ });
+
size_t itr = 0;
for (; itr < batches.size(); ++itr) {
auto& [batch, index] = batches[itr];
if (timeseries::bucket_catalog::claimWriteBatchCommitRights(*batch)) {
+ handledHere.insert(batch.get());
auto stmtIds = isTimeseriesWriteRetryable(opCtx)
? std::move(bucketStmtIds[batch->bucketHandle.bucketId.oid])
: std::vector<StmtId>{};
@@ -2929,6 +2940,8 @@ std::vector<size_t> performUnorderedTimeseriesWrites(
if (!canContinue) {
break;
}
+ } else if (!handledHere.contains(batch.get())) {
+ ++handledElsewhere;
}
}
diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
index 862e4c5b155..7c9e62792d1 100644
--- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
+++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.cpp
@@ -393,4 +393,11 @@ void appendExecutionStats(const BucketCatalog& catalog,
appendExecutionStatsToBuilder(*stats, builder);
}
+void reportMeasurementsGroupCommitted(BucketCatalog& catalog,
+ const NamespaceString& ns,
+ int64_t count) {
+ auto stats = internal::getOrInitializeExecutionStats(catalog, ns);
+ stats.incNumMeasurementsGroupCommitted(count);
+}
+
} // namespace mongo::timeseries::bucket_catalog
diff --git a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h
index 27954d14dca..03747337339 100644
--- a/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h
+++ b/src/mongo/db/timeseries/bucket_catalog/bucket_catalog.h
@@ -310,4 +310,14 @@ void appendExecutionStats(const BucketCatalog& catalog,
const NamespaceString& ns,
BSONObjBuilder& builder);
+/**
+ * Reports a number of measurements inserted that were committed by a different thread than the one
+ * that initially staged them. These measurements are considered to have benefitted from "group
+ * commit".
+ */
+void reportMeasurementsGroupCommitted(BucketCatalog& catalog,
+ const NamespaceString& ns,
+ int64_t count);
+
+
} // namespace mongo::timeseries::bucket_catalog
diff --git a/src/mongo/db/timeseries/bucket_catalog/execution_stats.cpp b/src/mongo/db/timeseries/bucket_catalog/execution_stats.cpp
index 174a15fa9ec..8ede3d295e1 100644
--- a/src/mongo/db/timeseries/bucket_catalog/execution_stats.cpp
+++ b/src/mongo/db/timeseries/bucket_catalog/execution_stats.cpp
@@ -103,6 +103,11 @@ void ExecutionStatsController::incNumCommits(long long increment) {
_globalStats.numCommits.fetchAndAddRelaxed(increment);
}
+void ExecutionStatsController::incNumMeasurementsGroupCommitted(long long increment) {
+ _collectionStats->numMeasurementsGroupCommitted.fetchAndAddRelaxed(increment);
+ _globalStats.numMeasurementsGroupCommitted.fetchAndAddRelaxed(increment);
+}
+
void ExecutionStatsController::incNumWaits(long long increment) {
_collectionStats->numWaits.fetchAndAddRelaxed(increment);
_globalStats.numWaits.fetchAndAddRelaxed(increment);
@@ -171,6 +176,8 @@ void appendExecutionStatsToBuilder(const ExecutionStats& stats, BSONObjBuilder&
auto commits = stats.numCommits.load();
builder.appendNumber("numCommits", commits);
+ builder.appendNumber("numMeasurementsGroupCommitted",
+ stats.numMeasurementsGroupCommitted.load());
builder.appendNumber("numWaits", stats.numWaits.load());
auto measurementsCommitted = stats.numMeasurementsCommitted.load();
builder.appendNumber("numMeasurementsCommitted", measurementsCommitted);
@@ -201,5 +208,4 @@ void appendExecutionStatsToBuilder(const ExecutionStats& stats, BSONObjBuilder&
}
}
-
} // namespace mongo::timeseries::bucket_catalog
diff --git a/src/mongo/db/timeseries/bucket_catalog/execution_stats.h b/src/mongo/db/timeseries/bucket_catalog/execution_stats.h
index 5b2b00c990a..d62da07571d 100644
--- a/src/mongo/db/timeseries/bucket_catalog/execution_stats.h
+++ b/src/mongo/db/timeseries/bucket_catalog/execution_stats.h
@@ -51,6 +51,7 @@ struct ExecutionStats {
AtomicWord<long long> numBucketsArchivedDueToMemoryThreshold;
AtomicWord<long long> numBucketsArchivedDueToTimeBackward;
AtomicWord<long long> numCommits;
+ AtomicWord<long long> numMeasurementsGroupCommitted;
AtomicWord<long long> numWaits;
AtomicWord<long long> numMeasurementsCommitted;
AtomicWord<long long> numBucketsReopened;
@@ -85,6 +86,7 @@ public:
void incNumBucketsArchivedDueToMemoryThreshold(long long increment = 1);
void incNumBucketsArchivedDueToTimeBackward(long long increment = 1);
void incNumCommits(long long increment = 1);
+ void incNumMeasurementsGroupCommitted(long long increment = 1);
void incNumWaits(long long increment = 1);
void incNumMeasurementsCommitted(long long increment = 1);
void incNumBucketsReopened(long long increment = 1);