diff options
author | Louis Williams <louis.williams@mongodb.com> | 2019-04-12 11:39:39 -0400 |
---|---|---|
committer | Louis Williams <louis.williams@mongodb.com> | 2019-04-12 11:39:39 -0400 |
commit | ee9c8b7d7382cb7f91b72c2e680f18016754ee35 (patch) | |
tree | 5481fcb8a9a6514a63cba6b699287b5aef2e61a3 /src/mongo/db/curop.h | |
parent | c6560dd65c6a2eac9f83045e6197d7dbce512c6e (diff) | |
download | mongo-ee9c8b7d7382cb7f91b72c2e680f18016754ee35.tar.gz |
SERVER-40105 Improve diagnostic information in currentOp for writeConflicts and prepareConflicts
Diffstat (limited to 'src/mongo/db/curop.h')
-rw-r--r-- | src/mongo/db/curop.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index a2466ffeeb2..ba1438f92a5 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -55,6 +55,17 @@ public: */ class AdditiveMetrics { public: + AdditiveMetrics() = default; + AdditiveMetrics(const AdditiveMetrics& other) { + this->add(other); + } + + AdditiveMetrics& operator=(const AdditiveMetrics& other) { + reset(); + add(other); + return *this; + } + /** * Adds all the fields of another AdditiveMetrics object together with the fields of this * AdditiveMetrics instance. @@ -62,10 +73,15 @@ public: void add(const AdditiveMetrics& otherMetrics); /** + * Resets all members to the default state. + */ + void reset(); + + /** * Returns true if the AdditiveMetrics object we are comparing has the same field values as * this AdditiveMetrics instance. */ - bool equals(const AdditiveMetrics& otherMetrics); + bool equals(const AdditiveMetrics& otherMetrics) const; /** * Increments writeConflicts by n. @@ -113,9 +129,15 @@ public: boost::optional<long long> keysInserted; // Number of index keys removed. boost::optional<long long> keysDeleted; + + // The following fields are atomic because they are reported by CurrentOp. This is an + // exception to the prescription that OpDebug only be used by the owning thread because + // these metrics are tracked over the course of a transaction by SingleTransactionStats, + // which is built on OpDebug. + // Number of read conflicts caused by a prepared transaction. - boost::optional<long long> prepareReadConflicts; - boost::optional<long long> writeConflicts; + AtomicWord<long long> prepareReadConflicts{0}; + AtomicWord<long long> writeConflicts{0}; }; OpDebug() = default; |