From 3e0d26cbdf7c6f8b3e6505138e3857094363cfee Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Tue, 21 Sep 2021 20:25:35 +0200 Subject: [PATCH] auth-4.5.x: try to reload rejected zones in bind-backend once every bind-check-interval --- modules/bindbackend/bindbackend2.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 669d78e99f..f97ce6f810 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -1041,12 +1041,12 @@ void Bind2Backend::queueReloadAndStore(unsigned int id) try { if (!safeGetBBDomainInfo(id, &bbold)) return; + bbold.d_checknow = false; BB2DomainInfo bbnew(bbold); /* make sure that nothing will be able to alter the existing records, we will load them from the zone file instead */ bbnew.d_records = LookButDontTouch(); parseZoneFile(&bbnew); - bbnew.d_checknow = false; bbnew.d_wasRejectedLastReload = false; safePutBBDomainInfo(bbnew); g_log << Logger::Warning << "Zone '" << bbnew.d_name << "' (" << bbnew.d_filename << ") reloaded" << endl; @@ -1056,6 +1056,7 @@ void Bind2Backend::queueReloadAndStore(unsigned int id) msg << " error at " + nowTime() + " parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.reason; g_log << Logger::Warning << " error parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.reason << endl; bbold.d_status = msg.str(); + bbold.d_lastcheck = time(nullptr); bbold.d_wasRejectedLastReload = true; safePutBBDomainInfo(bbold); } @@ -1064,6 +1065,7 @@ void Bind2Backend::queueReloadAndStore(unsigned int id) msg << " error at " + nowTime() + " parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.what(); g_log << Logger::Warning << " error parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.what() << endl; bbold.d_status = msg.str(); + bbold.d_lastcheck = time(nullptr); bbold.d_wasRejectedLastReload = true; safePutBBDomainInfo(bbold); } @@ -1179,11 +1181,6 @@ void Bind2Backend::lookup(const QType& qtype, const DNSName& qname, int zoneId, d_handle.qtype = qtype; d_handle.domain = std::move(domain); - if (!bbd.d_loaded) { - d_handle.reset(); - throw DBException("Zone for '" + d_handle.domain.toLogString() + "' in '" + bbd.d_filename + "' temporarily not available (file missing, or master dead)"); // fsck - } - if (!bbd.current()) { g_log << Logger::Warning << "Zone '" << d_handle.domain << "' (" << bbd.d_filename << ") needs reloading" << endl; queueReloadAndStore(bbd.d_id); @@ -1191,6 +1188,11 @@ void Bind2Backend::lookup(const QType& qtype, const DNSName& qname, int zoneId, throw DBException("Zone '" + bbd.d_name.toLogString() + "' (" + bbd.d_filename + ") gone after reload"); // if we don't throw here, we crash for some reason } + if (!bbd.d_loaded) { + d_handle.reset(); + throw DBException("Zone for '" + d_handle.domain.toLogString() + "' in '" + bbd.d_filename + "' not loaded (file missing, corrupt or master dead)"); // fsck + } + d_handle.d_records = bbd.d_records.get(); if (d_handle.d_records->empty()) -- 2.47.2