]> granicus.if.org Git - pdns/commitdiff
implement multiple master mode, plus make room in sql tables for multiple masters
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 7 Apr 2007 18:07:59 +0000 (18:07 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 7 Apr 2007 18:07:59 +0000 (18:07 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1017 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/backends/bind/bindparser.yy
pdns/communicator.cc
pdns/docs/pdns.sgml

index 5ffbb3e4e2564f01f68f02cbb2e575d5fd900579..a0897a782fad5e3297cad46866e5237bc8514999 100644 (file)
@@ -213,7 +213,9 @@ masters: /* empty */
 
 master: AWORD
        {
-               s_di.master=$1;
+               if(!s_di.master.empty())
+                 s_di.master.append(1, ' ');
+               s_di.master.append($1);
                free($1);
        }
        ;
index 5497e938e20eb2184ff7b7b10d46ac6f7814b15f..fc6019f1336aee6a1ee1e6b033ab2b0889bb9170 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002-2005  PowerDNS.COM BV
+    Copyright (C) 2002-2007  PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as 
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include "communicator.hh"
 #include <set>
-
+#include <boost/utility.hpp>
 #include "dnsbackend.hh"
 #include "ueberbackend.hh"
 #include "packethandler.hh"
@@ -64,7 +64,7 @@ void CommunicatorClass::suck(const string &domain,const string &remote)
   bool first=true;    
   try {
     Resolver resolver;
-    resolver.axfr(remote,domain.c_str());
+    resolver.axfr(remote, domain.c_str());
 
     UeberBackend *B=dynamic_cast<UeberBackend *>(P.getBackend());
 
@@ -250,37 +250,47 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P)
     Resolver resolver;   
     resolver.makeUDPSocket();  
     d_slaveschanged=true;
-    uint32_t ourserial=i->serial,theirserial=0;
+    uint32_t ourserial=i->serial, theirserial=0;
+    
+    if(d_havepriosuckrequest) {
+      d_havepriosuckrequest=false;
+      break;
+    }
 
-    try {
-      if(d_havepriosuckrequest) {
-       d_havepriosuckrequest=false;
+    vector<string> masters;
+    stringtok(masters, i->master, ", \t");
+    for(vector<string>::const_iterator iter = masters.begin(); iter != masters.end(); ++iter) {
+      try {
+       resolver.getSoaSerial(*iter, i->zone, &theirserial);
+       
+       if(theirserial<i->serial) {
+         L<<Logger::Error<<"Domain "<<i->zone<<" more recent than master, our serial "<<ourserial<<" > their serial "<<theirserial<<endl;
+         i->backend->setFresh(i->id);
+       }
+       else if(theirserial==i->serial) {
+         L<<Logger::Warning<<"Domain "<<i->zone<<" is fresh"<<endl;
+         i->backend->setFresh(i->id);
+       }
+       else {
+         L<<Logger::Warning<<"Domain "<<i->zone<<" is stale, master serial "<<theirserial<<", our serial "<<i->serial<<endl;
+         addSuckRequest(i->zone, *iter);
+       }
        break;
       }
-
-      resolver.getSoaSerial(i->master, i->zone, &theirserial);
-      
-      if(theirserial<i->serial) {
-       L<<Logger::Error<<"Domain "<<i->zone<<" more recent than master, our serial "<<ourserial<<" > their serial "<<theirserial<<endl;
-       i->backend->setFresh(i->id);
-      }
-      else if(theirserial==i->serial) {
-       L<<Logger::Warning<<"Domain "<<i->zone<<" is fresh"<<endl;
-       i->backend->setFresh(i->id);
+      catch(ResolverException &re) {
+       L<<Logger::Error<<"Error trying to retrieve/refresh '"+i->zone+"': "+re.reason<<endl;
+       if(next(iter) != masters.end()) 
+         L<<Logger::Error<<"Trying next master for '"+i->zone+"'"<<endl;
       }
-      else {
-       L<<Logger::Warning<<"Domain "<<i->zone<<" is stale, master serial "<<theirserial<<", our serial "<<i->serial<<endl;
-       addSuckRequest(i->zone,i->master);
+      catch(AhuException &re) {
+       L<<Logger::Error<<"Error trying to retrieve/refresh '"+i->zone+"': "+re.reason<<endl;
+       if(next(iter) != masters.end()) 
+         L<<Logger::Error<<"Trying next master for '"+i->zone+"'"<<endl;
       }
     }
-    catch(ResolverException &re) {
-      L<<Logger::Error<<"Error trying to retrieve/refresh '"+i->zone+"': "+re.reason<<endl;
-    }
   }
 }  
 
-
-
 int CommunicatorClass::doNotifications()
 {
   ComboAddress from;
index 52c24fb7a48631f08703b84afcb1a4a2c5dc5cf3..38d5ef6ba997aa39c04889902ca3e7a9bfac2c60 100644 (file)
@@ -5808,7 +5808,7 @@ name         IN            A        1.2.3.4
 create table domains (
  id             INT auto_increment,
  name           VARCHAR(255) NOT NULL,
- master                 VARCHAR(20) DEFAULT NULL,
+ master                 VARCHAR(128) DEFAULT NULL,
  last_check     INT DEFAULT NULL,
  type           VARCHAR(6) NOT NULL,
  notified_serial INT DEFAULT NULL, 
@@ -9596,7 +9596,7 @@ CREATE TABLE Zones (
 create table domains (
  id             INT auto_increment,
  name           VARCHAR(255) NOT NULL,
- master                 VARCHAR(20) DEFAULT NULL,
+ master                 VARCHAR(128) DEFAULT NULL,
  last_check     INT DEFAULT NULL,
  type           VARCHAR(6) NOT NULL,
  notified_serial INT DEFAULT NULL, 
@@ -9658,7 +9658,7 @@ CONSTRAINT `records_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domains`
 create table domains (
  id             SERIAL PRIMARY KEY,
  name           VARCHAR(255) NOT NULL,
- master                 VARCHAR(20) DEFAULT NULL,
+ master                 VARCHAR(128) DEFAULT NULL,
  last_check     INT DEFAULT NULL,
  type           VARCHAR(6) NOT NULL,
  notified_serial INT DEFAULT NULL, 
@@ -9718,7 +9718,7 @@ GRANT ALL ON records_id_seq TO pdns;
 create table domains (
  id             NUMBER,
  name           VARCHAR(255) NOT NULL,
- master                 VARCHAR(20) DEFAULT NULL,
+ master                 VARCHAR(128) DEFAULT NULL,
  last_check     INT DEFAULT NULL,
  type           VARCHAR(6) NOT NULL,
  notified_serial INT DEFAULT NULL, 
@@ -10332,7 +10332,7 @@ insert into domains (id,name,type) values (domains_id_sequence.nextval,'netherla
 create table Domains (
  ID             number(11) NOT NULL,
  NAME           VARCHAR(255) NOT NULL,
- MASTER                 VARCHAR(20) DEFAULT NULL,
+ MASTER                 VARCHAR(128) DEFAULT NULL,
  LAST_CHECK     INT DEFAULT NULL,
  TYPE           VARCHAR(6) NOT NULL,
  NOTIFIED_SERIAL INT DEFAULT NULL,
@@ -10435,7 +10435,7 @@ insert into Records (id,ZoneId, name,type,content,TimeToLive,Priority) select RE
             create table domains (
               id                INTEGER PRIMARY KEY,
               name              VARCHAR(255) NOT NULL,
-              master            VARCHAR(20) DEFAULT NULL,
+              master            VARCHAR(128) DEFAULT NULL,
               last_check        INTEGER DEFAULT NULL,
               type              VARCHAR(6) NOT NULL,
               notified_serial   INTEGER DEFAULT NULL,