From d9e4d82eb846637063c32fc8e32b337aff208f33 Mon Sep 17 00:00:00 2001 From: Sean Tao Date: Fri, 13 Jul 2018 16:28:03 -0400 Subject: SERVER-21167 Top keeps state about operations against non-existent collections --- src/mongo/db/stats/top.cpp | 8 +++++--- src/mongo/db/stats/top.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/mongo/db/stats') 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 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 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 _collDropNs; }; } // namespace mongo -- cgit v1.2.1