From: Chris Hofstaedtler Date: Mon, 14 Sep 2020 20:36:55 +0000 (+0200) Subject: slaveRefresh: avoid extra SOA lookups X-Git-Tag: auth-4.4.0-alpha2~12^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0b2cb182b0025b7f09bc9494bab071c73802af2;p=thirdparty%2Fpdns.git slaveRefresh: avoid extra SOA lookups For incoming NOTIFYs, we already call getDomainInfo, so reuse the serial from there. For unfresh domains, we already have a serial from the backend. However, a serial of 0 is now always considered stale. --- diff --git a/pdns/slavecommunicator.cc b/pdns/slavecommunicator.cc index f31d3d8d7f..a524069e39 100644 --- a/pdns/slavecommunicator.cc +++ b/pdns/slavecommunicator.cc @@ -900,7 +900,9 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) time_t now = time(0); for(auto& val : sdomains) { DomainInfo& di(val.di); - // might've come from the packethandler + // If our di comes from packethandler (caused by incoming NOTIFY), di.backend will not be filled out, + // and di.serial will not either. + // Conversely, if our di came from getUnfreshSlaveInfos, di.backend and di.serial are valid. if(!di.backend) { // Do not overwrite received DI just to make sure it exists in backend: // di.masters should contain the picked master (as first entry)! @@ -912,6 +914,7 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) // Backend for di still doesn't exist and this might cause us to // SEGFAULT on the setFresh command later on di.backend = tempdi.backend; + di.serial = tempdi.serial; } if(!ssr.d_freshness.count(di.id)) { // If we don't have an answer for the domain @@ -939,30 +942,15 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) d_failedSlaveRefresh.erase(di.zone); } - bool hasSOA = false; - SOAData sd; - sd.serial = 0; - try { - // Use UeberBackend cache for SOA. Cache gets cleared after AXFR/IXFR. - B->lookup(QType(QType::SOA), di.zone, di.id, nullptr); - DNSZoneRecord zr; - hasSOA = B->get(zr); - if (hasSOA) { - fillSOAData(zr, sd); - while(B->get(zr)); - } - } - catch(...) {} - uint32_t theirserial = ssr.d_freshness[di.id].theirSerial; - uint32_t ourserial = sd.serial; + uint32_t ourserial = di.serial; const ComboAddress remote = *di.masters.begin(); if(rfc1982LessThan(theirserial, ourserial) && ourserial != 0 && !::arg().mustDo("axfr-lower-serial")) { g_log< their serial "<< theirserial << endl; di.backend->setFresh(di.id); } - else if(hasSOA && theirserial == ourserial) { + else if(ourserial != 0 && theirserial == ourserial) { uint32_t maxExpire=0, maxInception=0; if(dk.isPresigned(di.zone)) { B->lookup(QType(QType::RRSIG), di.zone, di.id); // can't use DK before we are done with this lookup! @@ -1001,12 +989,11 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) } } else { - if(hasSOA) { + if (ourserial == 0) { + g_log<