summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.h
diff options
context:
space:
mode:
authorDevin Hilly <devin.hilly@mongodb.com>2018-11-13 17:55:50 -0500
committerDevin Hilly <devin.hilly@mongodb.com>2018-11-20 11:24:41 -0500
commit1862b00862a6ea9c3fdd08bba52ea6a016eccbc5 (patch)
treee0004fc325c86b0e4465fc602dd0d453df83bbec /src/mongo/db/db_raii.h
parentb92c7480df5406cb9487228af36cb10bb973e77c (diff)
downloadmongo-1862b00862a6ea9c3fdd08bba52ea6a016eccbc5.tar.gz
SERVER-31098 Wrong ns in system.profile for aggregation query
Diffstat (limited to 'src/mongo/db/db_raii.h')
-rw-r--r--src/mongo/db/db_raii.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/mongo/db/db_raii.h b/src/mongo/db/db_raii.h
index abc8b2280fe..39a30282630 100644
--- a/src/mongo/db/db_raii.h
+++ b/src/mongo/db/db_raii.h
@@ -39,22 +39,35 @@
namespace mongo {
/**
- * RAII-style class which automatically tracks the operation namespace in CurrentOp and records the
- * operation via Top upon destruction.
+ * RAII-style class which can update the diagnostic state on the operation's CurOp object and record
+ * the operation via Top upon destruction. Can be configured to only update the Top counters if
+ * desired.
*/
class AutoStatsTracker {
MONGO_DISALLOW_COPYING(AutoStatsTracker);
public:
/**
- * Sets the namespace of the CurOp object associated with 'opCtx' to be 'nss' and starts the
- * CurOp timer. 'lockType' describes which type of lock is held by this operation, and will be
- * used for reporting via Top. If 'dbProfilingLevel' is not given, this constructor will acquire
- * and then drop a database lock in order to determine the database's profiling level.
+ *Describes which diagnostics to update during the lifetime of this object.
+ */
+ enum class LogMode {
+ kUpdateTop, // Increments the Top counter for this operation type and this namespace upon
+ // destruction.
+ kUpdateTopAndCurop, // In addition to incrementing the Top counter, adjusts state on the
+ // CurOp object associated with the OperationContext. Updates the
+ // namespace to be 'nss', starts a timer for the operation (if it
+ // hasn't started already), and figures out and records the profiling
+ // level of the operation.
+ };
+
+ /**
+ * If 'logMode' is 'kUpdateTopAndCurop', sets up and records state on the CurOp object attached
+ * to 'opCtx', as described above.
*/
AutoStatsTracker(OperationContext* opCtx,
const NamespaceString& nss,
Top::LockType lockType,
+ LogMode logMode,
boost::optional<int> dbProfilingLevel,
Date_t deadline = Date_t::max());
@@ -66,6 +79,7 @@ public:
private:
OperationContext* _opCtx;
Top::LockType _lockType;
+ const NamespaceString _nss;
};
/**
@@ -143,7 +157,8 @@ public:
OperationContext* opCtx,
const NamespaceStringOrUUID& nsOrUUID,
AutoGetCollection::ViewMode viewMode = AutoGetCollection::ViewMode::kViewsForbidden,
- Date_t deadline = Date_t::max());
+ Date_t deadline = Date_t::max(),
+ AutoStatsTracker::LogMode logMode = AutoStatsTracker::LogMode::kUpdateTopAndCurop);
Database* getDb() const {
return _autoCollForRead.getDb();