]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Recover after failing to open a TCP connection to DNS server (#1861)
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 10 Jul 2024 10:30:33 +0000 (10:30 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 11 Jul 2024 16:57:49 +0000 (16:57 +0000)
    ERROR: Failed to connect to nameserver 127.0.0.1 using TCP.

After failing to establish a TCP connection to a DNS server, all DNS
queries that needed a TCP connection to that DNS server would timeout
because the nsvc object representing TCP connectivity got stuck in a
"queuing new queries but too busy to send any right now" state. Such
timeouts typically lead to HTTP 503 ERR_DNS_FAIL responses. This bug was
introduced when Comm closure handler registration was moved/delayed in
2010 commit cfd66529.

With this change, the affected nsvc object is destroyed, and Squid
attempts to open another TCP connection to the DNS server (when needed).
The original query is typically retried (subject to dns_timeout and
dns_retransmit_interval idiosyncrasies).

XXX: This fix increases the surface of reconfiguration and shutdown
problems documented in nsvc class destructor XXX.

src/dns_internal.cc

index fb09f8cc277404a7201298e8042ba9bb721d145f..e8c537b9ebaab97e9bd92c07842f1c6c4f2529ce 100644 (file)
@@ -857,6 +857,7 @@ idnsInitVCConnected(const Comm::ConnectionPointer &conn, Comm::Flag status, int,
         if (vc->ns < nameservers.size())
             nameservers[vc->ns].S.toStr(buf,MAX_IPSTRLEN);
         debugs(78, DBG_IMPORTANT, "ERROR: Failed to connect to nameserver " << buf << " using TCP.");
+        delete vc;
         return;
     }