Avoid underflow
@@ -317,7 +317,11 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl
if (my_stats.softDoomed()) {
double old = _stats.softDoomFactor();
fastos::TimeStamp softLimit = uint64_t((1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout());
- _stats.updatesoftDoomFactor(request.getTimeout(), softLimit, duration - my_stats.doomOvertime());
+ fastos::TimeStamp adjustedDuration = duration - my_stats.doomOvertime();
+ if (adjustedDuration < 0) {
+ adjustedDuration = 0;
+ }
+ _stats.updatesoftDoomFactor(request.getTimeout(), softLimit, adjustedDuration);
LOG(info, "Triggered softtimeout factor adjustment. request=%1.3f, doomOvertime=%1.3f, limit=%1.3f and duration=%1.3f, rankprofile=%s"
", factor adjusted from %1.3f to %1.3f",
request.getTimeout().sec(), my_stats.doomOvertime().sec(), softLimit.sec(), duration.sec(),
