diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2023-05-17 15:20:17 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-17 21:15:20 +0000 |
commit | a08bca73b8f75e02b12179cab18d9b9514330f8d (patch) | |
tree | 9c6b30abaa4178e6f89780a75be49d5a6ba2091b | |
parent | b6bb312c830b69e6d35349754680c50a6e2f279a (diff) | |
download | mongo-a08bca73b8f75e02b12179cab18d9b9514330f8d.tar.gz |
SERVER-77153 Protect against zero elapsed time in throughput probing
(cherry picked from commit b46ba042fdce866cb42bca247febecde398fd1c4)
-rw-r--r-- | src/mongo/db/storage/execution_control/throughput_probing.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/db/storage/execution_control/throughput_probing.cpp b/src/mongo/db/storage/execution_control/throughput_probing.cpp index 67201bd9032..d18ed17dd73 100644 --- a/src/mongo/db/storage/execution_control/throughput_probing.cpp +++ b/src/mongo/db/storage/execution_control/throughput_probing.cpp @@ -111,6 +111,12 @@ void ThroughputProbing::_run(Client* client) { } double elapsed = _timer.micros(); + if (elapsed == 0) { + // The clock used to sleep between iterations may not be reliable, and thus the timer may + // report that no time has elapsed. If this occurs, just wait for the next iteration. + return; + } + auto throughput = (numFinishedProcessing - _prevNumFinishedProcessing) / elapsed; _stats.opsPerSec.store(throughput * 1'000'000); |