]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: speedup getUpdatedMasters() for the gsql backends 7460/head
authorKees Monshouwer <mind04@monshouwer.org>
Wed, 6 Feb 2019 21:28:10 +0000 (22:28 +0100)
committermind04 <mind04@monshouwer.org>
Thu, 7 Feb 2019 08:42:03 +0000 (09:42 +0100)
modules/gmysqlbackend/gmysqlbackend.cc
modules/godbcbackend/godbcbackend.cc
modules/gpgsqlbackend/gpgsqlbackend.cc
modules/gsqlite3backend/gsqlite3backend.cc
pdns/backends/gsql/gsqlbackend.cc

index e3033abe3b1a7a2a68b5ca93b01b17cf4b45451c..6bdb5fa3e78a4abc13f3f4027b2a366dc5c2d599 100644 (file)
@@ -120,7 +120,7 @@ public:
     declare(suffix,"update-account-query","", "update domains set account=? where name=?");
     declare(suffix,"update-serial-query","", "update domains set notified_serial=? where id=?");
     declare(suffix,"update-lastcheck-query","", "update domains set last_check=? where id=?");
-    declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
+    declare(suffix,"info-all-master-query","", "select d.id, d.name, d.notified_serial, r.content from records r join domains d on r.name=d.name where r.type='SOA' and r.disabled=0 and d.type='MASTER'");
     declare(suffix,"delete-domain-query","", "delete from domains where name=?");
     declare(suffix,"delete-zone-query","", "delete from records where domain_id=?");
     declare(suffix,"delete-rrset-query","","delete from records where domain_id=? and name=? and type=?");
index 7334df4c9d5e0c71a7d7de21ad19978ea1e4965e..533f50f959b39c0bce226bd0430a208d647a4e79 100644 (file)
@@ -107,7 +107,7 @@ public:
     declare(suffix,"update-account-query","", "update domains set account=? where name=?");
     declare(suffix,"update-serial-query","", "update domains set notified_serial=? where id=?");
     declare(suffix,"update-lastcheck-query","", "update domains set last_check=? where id=?");
-    declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
+    declare(suffix,"info-all-master-query","", "select domains.id, domains.name, domains.notified_serial, records.content from records join domains on records.name=domains.name where records.type='SOA' and records.disabled=0 and domains.type='MASTER'");
     declare(suffix,"delete-domain-query","", "delete from domains where name=?");
     declare(suffix,"delete-zone-query","", "delete from records where domain_id=?");
     declare(suffix,"delete-rrset-query","","delete from records where domain_id=? and name=? and type=?");
index 641f74bb1b6498add1c3e650ae8f893df89afa95..cc1c601de87dc619328f94d236f852d77083588a 100644 (file)
@@ -129,7 +129,7 @@ public:
     declare(suffix,"update-account-query","", "update domains set account=$1 where name=$2");
     declare(suffix,"update-serial-query","", "update domains set notified_serial=$1 where id=$2");
     declare(suffix,"update-lastcheck-query","", "update domains set last_check=$1 where id=$2");
-    declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
+    declare(suffix,"info-all-master-query","", "select domains.id, domains.name, domains.notified_serial, records.content from records join domains on records.name=domains.name where records.type='SOA' and records.disabled=false and domains.type='MASTER'");
     declare(suffix,"delete-domain-query","", "delete from domains where name=$1");
     declare(suffix,"delete-zone-query","", "delete from records where domain_id=$1");
     declare(suffix,"delete-rrset-query","","delete from records where domain_id=$1 and name=$2 and type=$3");
index f9cb892fcbf911ed48c5de947edbef65b755a8cf..28eddf2aa0826c1c0f53777aa62bf20083eb2779 100644 (file)
@@ -119,7 +119,7 @@ public:
     declare(suffix, "update-account-query","", "update domains set account=:account where name=:domain");
     declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id");
     declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id");
-    declare(suffix, "info-all-master-query", "", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
+    declare(suffix, "info-all-master-query", "", "select domains.id, domains.name, domains.notified_serial, records.content from records join domains on records.name=domains.name where records.type='SOA' and records.disabled=0 and domains.type='MASTER'");
     declare(suffix, "delete-domain-query","", "delete from domains where name=:domain");
     declare(suffix, "delete-zone-query", "", "delete from records where domain_id=:domain_id");
     declare(suffix, "delete-rrset-query", "", "delete from records where domain_id=:domain_id and name=:qname and type=:qtype");
index 74864b0047acae38ecd7f0857d4f4186b8ef58da..5e4d9070cad10a2c453bf6bab159799da16e35eb 100644 (file)
@@ -375,7 +375,7 @@ void GSQLBackend::getUnfreshSlaveInfos(vector<DomainInfo> *unfreshDomains)
 void GSQLBackend::getUpdatedMasters(vector<DomainInfo> *updatedDomains)
 {
   /* list all domains that need notifications for which we are master, and insert into updatedDomains
-     id,name,master IP,serial */
+     id, name, notified_serial, serial */
   try {
     reconnectIfNeeded();
 
@@ -388,32 +388,33 @@ void GSQLBackend::getUpdatedMasters(vector<DomainInfo> *updatedDomains)
     throw PDNSException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
   }
 
-  vector<DomainInfo> allMasters;
   size_t numanswers=d_result.size();
-  for(size_t n=0;n<numanswers;++n) { // id,name,master,last_check,notified_serial
-    DomainInfo sd;
-    ASSERT_ROW_COLUMNS("info-all-master-query", d_result[n], 6);
-    sd.id=pdns_stou(d_result[n][0]);
+  vector<string>parts;
+  DomainInfo di;
+
+  di.backend = this;
+  di.kind = DomainInfo::Master;
+
+  for( size_t n = 0; n < numanswers; ++n ) { // id, name, notified_serial, content
+    ASSERT_ROW_COLUMNS( "info-all-master-query", d_result[n], 4 );
+
+    parts.clear();
+    stringtok( parts, d_result[n][3] );
+
     try {
-      sd.zone= DNSName(d_result[n][1]);
-    } catch (...) {
-      continue;
-    }
-    sd.last_check=pdns_stou(d_result[n][3]);
-    sd.notified_serial=pdns_stou(d_result[n][4]);
-    sd.backend=this;
-    sd.kind=DomainInfo::Master;
-    allMasters.push_back(sd);
-  }
+      uint32_t serial = parts.size() > 2 ? pdns_stou(parts[2]) : 0;
+      uint32_t notified_serial = pdns_stou( d_result[n][2] );
 
-  for(vector<DomainInfo>::iterator i=allMasters.begin();i!=allMasters.end();++i) {
-    SOAData sdata;
-    sdata.serial=0;
-    sdata.refresh=0;
-    getSOA(i->zone,sdata);
-    if(i->notified_serial!=sdata.serial) {
-      i->serial=sdata.serial;
-      updatedDomains->push_back(*i);
+      if( serial != notified_serial ) {
+        di.id = pdns_stou( d_result[n][0] );
+        di.zone = DNSName( d_result[n][1] );
+        di.serial = serial;
+        di.notified_serial = notified_serial;
+
+        updatedDomains->emplace_back(di);
+      }
+    } catch ( ... ) {
+      continue;
     }
   }
 }