From 7c17e62e18f4057cb53a70666f0afb7537262699 Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Mon, 2 Feb 2026 10:46:55 +0900 Subject: [PATCH 1/3] Fix HostDBInfo::is_down condition --- include/iocore/hostdb/HostDBProcessor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/iocore/hostdb/HostDBProcessor.h b/include/iocore/hostdb/HostDBProcessor.h index fded833c509..e32f4875301 100644 --- a/include/iocore/hostdb/HostDBProcessor.h +++ b/include/iocore/hostdb/HostDBProcessor.h @@ -233,7 +233,7 @@ inline bool HostDBInfo::is_down(ts_time now, ts_seconds fail_window) { auto last_fail = this->last_fail_time(); - return (last_fail != TS_TIME_ZERO) && (last_fail + fail_window < now); + return (last_fail != TS_TIME_ZERO) && (last_fail + fail_window >= now); } inline bool From c0735a3fedc631832a159d2cea5bf6954c730e1e Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Tue, 3 Feb 2026 10:56:22 +0900 Subject: [PATCH 2/3] Add comments --- include/iocore/hostdb/HostDBProcessor.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/iocore/hostdb/HostDBProcessor.h b/include/iocore/hostdb/HostDBProcessor.h index e32f4875301..1916ba46354 100644 --- a/include/iocore/hostdb/HostDBProcessor.h +++ b/include/iocore/hostdb/HostDBProcessor.h @@ -229,11 +229,24 @@ HostDBInfo::is_alive() return this->last_fail_time() == TS_TIME_ZERO; } +/** + Check if this HostDBInfo is currently marked down (true) or not (false). Returns true while within the `fail_window` period after + `last_failure`. Once `fail_window` expires, the host is treated as UP and this function returns false. + + |<-- fail_window -->| + ----------------+-------------------+-----------------> time + UP | DOWN | UP + (is_down=false) | (is_down=true) | (is_down=false) + | | + ^ ^ + \ \ + last_failure last_failure + fail_window + */ inline bool HostDBInfo::is_down(ts_time now, ts_seconds fail_window) { auto last_fail = this->last_fail_time(); - return (last_fail != TS_TIME_ZERO) && (last_fail + fail_window >= now); + return (last_fail != TS_TIME_ZERO) && (now <= last_fail + fail_window); } inline bool From a877c50b162719e84928e21efb1adff10e7260ff Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Tue, 3 Feb 2026 11:12:15 +0900 Subject: [PATCH 3/3] Polish commnet --- include/iocore/hostdb/HostDBProcessor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/iocore/hostdb/HostDBProcessor.h b/include/iocore/hostdb/HostDBProcessor.h index 1916ba46354..578822f39e8 100644 --- a/include/iocore/hostdb/HostDBProcessor.h +++ b/include/iocore/hostdb/HostDBProcessor.h @@ -230,7 +230,7 @@ HostDBInfo::is_alive() } /** - Check if this HostDBInfo is currently marked down (true) or not (false). Returns true while within the `fail_window` period after + Check if this HostDBInfo is currently marked DOWN (true) or UP (false). Returns true while within the `fail_window` period after `last_failure`. Once `fail_window` expires, the host is treated as UP and this function returns false. |<-- fail_window -->| @@ -240,7 +240,7 @@ HostDBInfo::is_alive() | | ^ ^ \ \ - last_failure last_failure + fail_window + last_failure last_failure + fail_window */ inline bool HostDBInfo::is_down(ts_time now, ts_seconds fail_window)