diff --git a/src/iocore/hostdb/HostDB.cc b/src/iocore/hostdb/HostDB.cc index f30246b8c74..12a8532be6e 100644 --- a/src/iocore/hostdb/HostDB.cc +++ b/src/iocore/hostdb/HostDB.cc @@ -1324,7 +1324,9 @@ HostDBRecord::select_best_http(ts_time now, ts_seconds fail_window, sockaddr con } } } else { - best_alive = &info[0]; + if (info[0].select(now, fail_window)) { + best_alive = &info[0]; + } } return best_alive; diff --git a/tests/gold_tests/dns/dns_host_down.test.py b/tests/gold_tests/dns/dns_host_down.test.py index 74930c75443..3d05805769a 100644 --- a/tests/gold_tests/dns/dns_host_down.test.py +++ b/tests/gold_tests/dns/dns_host_down.test.py @@ -55,24 +55,13 @@ def _configure_trafficserver(self): 'proxy.config.hostdb.host_file.path': os.path.join(Test.TestDirectory, "hosts_file"), }) - # Even when the origin server is down, SM will return a hit-fresh domain from HostDB. - # After request has failed, SM should mark the IP as down def _test_host_mark_down(self): tr = Test.AddTestRun() tr.Processes.Default.StartBefore(self._server) tr.Processes.Default.StartBefore(self._ts) - tr.AddVerifierClientProcess( - "client-1", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port], other_args='--keys 1') - - # After host has been marked down from previous test, HostDB should not return - # the host as available and DNS lookup should fail. - def _test_host_unreachable(self): - tr = Test.AddTestRun() - - tr.AddVerifierClientProcess( - "client-2", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port], other_args='--keys 2') + tr.AddVerifierClientProcess("client-1", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port]) # Verify error log marking host down exists def _test_error_log(self): @@ -86,7 +75,6 @@ def _test_error_log(self): def run(self): self._test_host_mark_down() - self._test_host_unreachable() self._test_error_log() diff --git a/tests/gold_tests/dns/replay/server_down.replay.yaml b/tests/gold_tests/dns/replay/server_down.replay.yaml index d5b33bc7844..52fbead2894 100644 --- a/tests/gold_tests/dns/replay/server_down.replay.yaml +++ b/tests/gold_tests/dns/replay/server_down.replay.yaml @@ -36,6 +36,7 @@ sessions: status: 200 # Returns 502 since server connection is unreachable + # This transaction should mark the IP as down proxy-response: status: 502 @@ -55,5 +56,7 @@ sessions: server-response: status: 200 + # After host has been marked down from previous test, HostDB should not return + # the host as available and HostDB lookup should fail. proxy-response: - status: 502 + status: 500