]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: try to reload rejected zones in bind-backend once every bind-check-interval 10748/head
authorKees Monshouwer <mind04@monshouwer.org>
Tue, 21 Sep 2021 18:25:35 +0000 (20:25 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 23 Sep 2021 07:47:29 +0000 (09:47 +0200)
modules/bindbackend/bindbackend2.cc

index 8ec953ac4d0dd60575cd82e8c5cb2771498b313a..933302b7262189d369a93a87b4905730d388a180 100644 (file)
@@ -1038,12 +1038,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<recordstorage_t>();
     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;
@@ -1051,16 +1051,18 @@ void Bind2Backend::queueReloadAndStore(unsigned int id)
   catch (PDNSException& ae) {
     ostringstream msg;
     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;
+    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);
   }
   catch (std::exception& ae) {
     ostringstream msg;
     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;
+    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);
   }
@@ -1176,11 +1178,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);
@@ -1188,6 +1185,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())