From b46ba042fdce866cb42bca247febecde398fd1c4 Mon Sep 17 00:00:00 2001 From: Gregory Noma Date: Wed, 17 May 2023 15:20:17 +0000 Subject: SERVER-77153 Protect against zero elapsed time in throughput probing --- src/mongo/db/storage/execution_control/throughput_probing.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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); -- cgit v1.2.1