diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-06-22 10:56:37 -0400 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2018-07-02 13:29:25 -0400 |
commit | 334962f32bd1e241083057877ad99c334a9aa759 (patch) | |
tree | 6ffc89bd1df37b3553b14d5a47b8525e41a9d74f /src/mongo/shell/bench.h | |
parent | bed5e03f5462243ca3159d94172aca9adac3294a (diff) | |
download | mongo-334962f32bd1e241083057877ad99c334a9aa759.tar.gz |
SERVER-35602 Add support to benchRun for atClusterTime reads with adjustable getMore delays
Diffstat (limited to 'src/mongo/shell/bench.h')
-rw-r--r-- | src/mongo/shell/bench.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/mongo/shell/bench.h b/src/mongo/shell/bench.h index 136e6825c2e..c335af687a1 100644 --- a/src/mongo/shell/bench.h +++ b/src/mongo/shell/bench.h @@ -96,6 +96,20 @@ public: BSONObj writeConcern; BSONObj value; + // Only used for find cmds when set greater than 0. A find operation will retrieve the latest + // cluster time from the oplog and randomly chooses a time between that timestamp and + // 'useClusterTimeWithinSeconds' seconds in the past at which to read. + // + // Must be used with 'useSnapshotReads=true' BenchRunConfig because atClusterTime is only + // allowed within a transaction. + int useAClusterTimeWithinPastSeconds = 0; + + // Delays getMore commands following a find cmd. A uniformly distributed random value between 0 + // and maxRandomMillisecondDelayBeforeGetMore will be generated for each getMore call. Useful + // for keeping a snapshot read open for a longer time duration, say to simulate the basic + // resources that a snapshot transaction would hold for a time. + int maxRandomMillisecondDelayBeforeGetMore{0}; + // This is an owned copy of the raw operation. All unowned members point into this. BSONObj myBsonOp; }; @@ -172,6 +186,11 @@ public: */ bool useSnapshotReads{false}; + /** + * How many milliseconds to sleep for if an operation fails, before continuing to the next op. + */ + Milliseconds delayMillisOnFailedOperation{0}; + /// Base random seed for threads int64_t randomSeed; @@ -221,6 +240,10 @@ public: * Count one instance of the event, which took "timeMicros" microseconds. */ void countOne(long long timeMicros) { + if (_numEvents == std::numeric_limits<long long>::max()) { + fassertFailedWithStatus(50874, + {ErrorCodes::Overflow, "Overflowed the events counter."}); + } ++_numEvents; _totalTimeMicros += timeMicros; } @@ -235,13 +258,13 @@ public: /** * Get the number of observed events. */ - unsigned long long getNumEvents() const { + long long getNumEvents() const { return _numEvents; } private: long long _totalTimeMicros{0}; - unsigned long long _numEvents{0}; + long long _numEvents{0}; }; /** @@ -455,7 +478,7 @@ private: BenchRunState& _brState; - const int64_t _randomSeed; + PseudoRandom _rng; // Dummy stats to use before observation period. BenchRunStats _statsBlackHole; |