d_cont.clear();
}
+ void clear(const Thing& thing)
+ {
+ d_cont.erase(thing);
+ }
void prune(time_t now)
{
auto& ind = d_cont.template get<time_t>();
bool SyncRes::isThrottled(time_t now, const ComboAddress& server)
{
+ // Give fully throttled servers a chance to be used, to avoid having one bad domain spoil the NS record for others
+ // If the NS answers, it will be unThrottled
+ if ((dns_random_uint32() & 0x7f) == 0) {
+ return false;
+ }
return s_throttle.lock()->shouldThrottle(now, std::tuple(server, g_rootdnsname, 0));
}
+void SyncRes::unThrottle(const ComboAddress& server, const DNSName& name, QType qtype)
+{
+ s_throttle.lock()->clear(std::tuple(server, g_rootdnsname, 0));
+ s_throttle.lock()->clear(std::tuple(server, name, qtype));
+}
+
void SyncRes::doThrottle(time_t now, const ComboAddress& server, time_t duration, unsigned int tries)
{
s_throttle.lock()->throttle(now, std::tuple(server, g_rootdnsname, 0), duration, tries);
LOG(prefix << qname << ": Error resolving from " << remoteIP.toString() << (doTCP ? " over TCP" : "") << ", possible error: " << stringerror() << endl);
}
+ // don't account for resource limits, they are our own fault
+ // And don't throttle when the IP address is on the dontThrottleNetmasks list or the name is part of dontThrottleNames
if (resolveret != LWResult::Result::OSLimitError && !chained && !dontThrottle) {
- // don't account for resource limits, they are our own fault
- // And don't throttle when the IP address is on the dontThrottleNetmasks list or the name is part of dontThrottleNames
s_nsSpeeds.lock()->find_or_enter(nsName.empty() ? DNSName(remoteIP.toStringWithPort()) : nsName, d_now).submit(remoteIP, 1000000, d_now); // 1 sec
- // code below makes sure we don't filter COM or the root
- if (s_serverdownmaxfails > 0 && (auth != g_rootdnsname) && s_fails.lock()->incr(remoteIP, d_now) >= s_serverdownmaxfails) {
+ // make sure we don't throttle the root
+ if (s_serverdownmaxfails > 0 && auth != g_rootdnsname && s_fails.lock()->incr(remoteIP, d_now) >= s_serverdownmaxfails) {
LOG(prefix << qname << ": Max fails reached resolving on " << remoteIP.toString() << ". Going full throttle for " << s_serverdownthrottletime << " seconds" << endl);
// mark server as down
doThrottle(d_now.tv_sec, remoteIP, s_serverdownthrottletime, 10000);
if (s_serverdownmaxfails > 0) {
s_fails.lock()->clear(remoteIP);
}
+ // Clear all throttles for this IP, both general and specific throttles for qname-qtype
+ unThrottle(remoteIP, qname, qtype);
if (lwr.d_tcbit) {
truncated = true;
static bool isThrottled(time_t now, const ComboAddress& server);
static void doThrottle(time_t now, const ComboAddress& server, time_t duration, unsigned int tries);
static void doThrottle(time_t now, const ComboAddress& server, const DNSName& name, QType qtype, time_t duration, unsigned int tries);
+ static void unThrottle(const ComboAddress& server, const DNSName& qname, QType qtype);
static uint64_t getFailedServersSize();
static void clearFailedServers();