]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: dns: prevent ds accumulation within dss
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 29 Apr 2025 08:22:38 +0000 (10:22 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 29 Apr 2025 19:20:54 +0000 (21:20 +0200)
commit5288b39011b2449bfa896f7932c7702b5a85ee77
tree48af114415afc6f0cb236cf6891c060375e39ced
parent14ebe95a10e7fdc003e369b58463a4744e88fa8e
BUG/MINOR: dns: prevent ds accumulation within dss

when dns session callback (dns_session_release()) is called upon error
(ie: when some pending queries were not sent), we try our best to
re-create the applet in order to preserve the pending queries and give
them a chance to be retried. This is done at the end of
dns_session_release().

However, doing so exposes to an issue: if the error preventing queries
from being sent is still encountered over and over the dns session could
stay there indefinitely. Meanwhile, other dns sessions may be created on
the same dns_stream_server periodically. If previous failing dns sessions
don't terminate but we also keep creating new ones, we end up accumulating
failing sessions on a given dns_stream_server, which can eventually cause
ressource shortage.

This issue was found when trying to address ("BUG/MINOR: dns: add tempo
between 2 connection attempts for dns servers")

To fix it, we track the number of failed consecutive sessions for a given
dns server. When we reach the threshold (set to 100), we consider that the
link to the dns server is broken (at least temporarily) and we force
dns_session_new() to fail, so that we stop creating new sessions until one
of the existing one eventually succeeds.

A workaround for this fix consists in setting the "maxconn" parameter on
nameserver directive (under resolvers section) to a reasonnable value so
that no more than "maxconn" sessions may co-exist on the same server at
a given time.

This may be backported to all stable versions.
("CLEANUP: dns: remove unused dns_stream_server struct member") may be
backported to ease the backport.
include/haproxy/dns-t.h
src/dns.c