diff --git a/include/tscore/Diags.h b/include/tscore/Diags.h index e9e050f60ac..d87baec412c 100644 --- a/include/tscore/Diags.h +++ b/include/tscore/Diags.h @@ -188,14 +188,16 @@ is_dbg_ctl_enabled(DbgCtl const &ctl) } \ } while (false) -#define Debug_bw(tag, fmt, ...) \ - do { \ - if (unlikely(diags->on())) { \ - static const SourceLocation loc = MakeSourceLocation(); \ - static LogMessage log_message; \ - log_message.debug(tag, loc, "%s", ts::bwprint(ts::bw_dbg, fmt, __VA_ARGS__).c_str()); \ - } \ - } while (0) +// A BufferWriter version of Debug(). +#define Debug_bw(tag__, fmt, ...) \ + do { \ + if (unlikely(diags()->on())) { \ + static DbgCtl Debug_bw_ctl(tag__); \ + if (Debug_bw_ctl.ptr()->on) { \ + DbgPrint(Debug_bw_ctl, "%s", ts::bwprint(ts::bw_dbg, fmt, __VA_ARGS__).c_str()); \ + } \ + } \ + } while (false) // printf-like debug output. First parameter must be tag (C-string literal, or otherwise // a constexpr returning char const pointer to null-terminated C-string). diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 71fcb46e7ba..813b6032cde 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -5474,10 +5474,10 @@ HttpSM::mark_host_failure(ResolveInfo *info, ts_time time_down) int host_len; const char *host_name_ptr = t_state.unmapped_url.host_get(&host_len); std::string_view host_name{host_name_ptr, size_t(host_len)}; - ts::bwprint(error_bw_buffer,"CONNECT : {::s} connecting to {} for host='{}' url='{}' marking down", - ts::bwf::Errno(t_state.current.server->connect_result), t_state.current.server->dst_addr,host_name, - ts::bwf::FirstOf(url_str, "")); - Log::error("%s", error_bw_buffer.c_str()); + ts::bwprint(error_bw_buffer, "CONNECT : {::s} connecting to {} for host='{}' url='{}' marking down", + ts::bwf::Errno(t_state.current.server->connect_result), t_state.current.server->dst_addr, host_name, + ts::bwf::FirstOf(url_str, "")); + Log::error("%s", error_bw_buffer.c_str()); if (url_str) { t_state.arena.str_free(url_str); diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index a27af518e76..9f660d4207c 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -1790,6 +1790,12 @@ HttpTransact::PPDNSLookup(State *s) markParentDown(s); // DNS lookup of parent failed, find next parent or o.s. if (find_server_and_update_current_info(s) == ResolveInfo::HOST_NONE) { + if (is_cache_hit(s->cache_lookup_result) && is_stale_cache_response_returnable(s)) { + s->source = SOURCE_CACHE; + TxnDebug("http_trans", "All parents are down, serving stale doc to client"); + build_response_from_cache(s, HTTP_WARNING_CODE_REVALIDATION_FAILED); + return; + } ink_assert(s->current.request_to == ResolveInfo::HOST_NONE); handle_parent_died(s); return; diff --git a/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py b/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py index e012d394f74..e799884c6d8 100644 --- a/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py +++ b/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py @@ -47,7 +47,7 @@ def _configure_ts(self): 'proxy.config.http.cache.max_stale_age': 10, 'proxy.config.http.parent_proxy.self_detect': 0, 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|dns|parent_proxy', + 'proxy.config.diags.debug.tags': 'cache|http|dns|hostdb|parent_proxy', }) self.ts_child.Disk.parent_config.AddLine( f'dest_domain=. parent="{self.ts_parent_hostname}" round_robin=consistent_hash go_direct=false'