summaryrefslogtreecommitdiff
path: root/src/mongo/db/stats
diff options
context:
space:
mode:
authorSean Tao <sean.tao@10gen.com>2018-07-13 16:28:03 -0400
committerSean Tao <sean.tao@10gen.com>2018-07-23 16:19:46 -0400
commitd9e4d82eb846637063c32fc8e32b337aff208f33 (patch)
treee052f874d8f82efe0c29c3778228ee5787756ddf /src/mongo/db/stats
parent0f1e346b3bd125322903c682e570da1f7770c4da (diff)
downloadmongo-d9e4d82eb846637063c32fc8e32b337aff208f33.tar.gz
SERVER-21167 Top keeps state about operations against non-existent collections
Diffstat (limited to 'src/mongo/db/stats')
-rw-r--r--src/mongo/db/stats/top.cpp8
-rw-r--r--src/mongo/db/stats/top.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp
index 45680f7db15..155f122fef5 100644
--- a/src/mongo/db/stats/top.cpp
+++ b/src/mongo/db/stats/top.cpp
@@ -85,8 +85,9 @@ void Top::record(OperationContext* opCtx,
auto hashedNs = UsageMap::HashedKey(ns);
stdx::lock_guard<SimpleMutex> lk(_lock);
- if ((command || logicalOp == LogicalOp::opQuery) && ns == _lastDropped) {
- _lastDropped = "";
+ if ((command || logicalOp == LogicalOp::opQuery) &&
+ _collDropNs.find(ns.toString()) != _collDropNs.end()) {
+ _collDropNs.erase(ns.toString());
return;
}
@@ -142,10 +143,11 @@ void Top::_record(OperationContext* opCtx,
void Top::collectionDropped(StringData ns, bool databaseDropped) {
stdx::lock_guard<SimpleMutex> lk(_lock);
_usage.erase(ns);
+
if (!databaseDropped) {
// If a collection drop occurred, there will be a subsequent call to record for this
// collection namespace which must be ignored. This does not apply to a database drop.
- _lastDropped = ns.toString();
+ _collDropNs.insert(ns.toString());
}
}
diff --git a/src/mongo/db/stats/top.h b/src/mongo/db/stats/top.h
index ccd4ac5e13f..6dc2cf7f8a3 100644
--- a/src/mongo/db/stats/top.h
+++ b/src/mongo/db/stats/top.h
@@ -143,7 +143,7 @@ private:
mutable SimpleMutex _lock;
OperationLatencyHistogram _globalHistogramStats;
UsageMap _usage;
- std::string _lastDropped;
+ std::set<std::string> _collDropNs;
};
} // namespace mongo