summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/memory_usage_tracker.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/memory_usage_tracker.h')
-rw-r--r--src/mongo/db/pipeline/memory_usage_tracker.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/memory_usage_tracker.h b/src/mongo/db/pipeline/memory_usage_tracker.h
index 8bf1e6437c6..275183081ef 100644
--- a/src/mongo/db/pipeline/memory_usage_tracker.h
+++ b/src/mongo/db/pipeline/memory_usage_tracker.h
@@ -29,6 +29,7 @@
#pragma once
+#include <algorithm>
#include <memory>
#include <utility>
@@ -49,11 +50,20 @@ public:
PerFunctionMemoryTracker() = delete;
void update(long long diff) {
- tassert(5578603,
- str::stream() << "Underflow on memory tracking, attempting to add " << diff
- << " but only " << _currentMemoryBytes << " available",
- diff >= 0 || _currentMemoryBytes >= std::abs(diff));
- set(_currentMemoryBytes + diff);
+
+ // TODO SERVER-61281: this is a temporary measure in tackling the problem in this
+ // ticket. It prevents the underflow from happening but doesn't address the cause
+ // which is inaccurate tracking.
+ // Once inaccurate tracking is resolved, the underflow assertion below could be
+ // restored.
+ // tassert(5578603,
+ // str::stream() << "Underflow on memory tracking, attempting to add " <<
+ // diff
+ // << " but only " << _currentMemoryBytes << " available",
+ // diff >= 0 || _currentMemoryBytes >= std::abs(diff));
+ // set(_currentMemoryBytes + diff);
+
+ set(std::max(_currentMemoryBytes + diff, 0LL));
}
void set(long long total) {