BIND 10 master, updated. 0a9abd16730fa7708967c4b17dd1a36b7c75f363 Changelog for #2877

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Apr 10 07:38:01 UTC 2013


The branch, master has been updated
       via  0a9abd16730fa7708967c4b17dd1a36b7c75f363 (commit)
       via  33bd949ac7288c61ed0a664b7329b50b36d180e5 (commit)
       via  21d0817bae3a1aded59cf3809bff5856dbba792a (commit)
       via  dd7864295bd032ad3a832a6ba7d35d13b89dc922 (commit)
       via  f8af3f0612dd39b81283af83b5a930d0754dacf8 (commit)
       via  583b148b75060920bf8f394239973caa3868993f (commit)
       via  15783473147022e77c16fea2c314abb5b1db0ade (commit)
       via  8662231f00b931f1d72c260c1d82fd598caaf840 (commit)
       via  b8387e4c0167f8521dc34ab14214bc79ac847c4b (commit)
      from  ee44f96ae1e8556fa04077f708287cb017dbbd0e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0a9abd16730fa7708967c4b17dd1a36b7c75f363
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Apr 10 09:17:28 2013 +0200

    Changelog for #2877

commit 33bd949ac7288c61ed0a664b7329b50b36d180e5
Merge: ee44f96 21d0817
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Apr 10 09:11:12 2013 +0200

    Merge #2877
    
    Fix SQLite backend so the deletes are not so slow.
    
    This is the urgent part of the fix; we'll have another half of the branch
    later, to clean up some details.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |   12 +++++++++
 src/lib/datasrc/database.cc                        |   15 ++++++++++-
 src/lib/datasrc/database.h                         |   14 ++++++++++-
 src/lib/datasrc/datasrc_messages.mes               |   26 ++++++++++++++++++++
 src/lib/datasrc/sqlite3_accessor.cc                |   26 ++++++++++++++++----
 src/lib/datasrc/tests/sqlite3_accessor_unittest.cc |    9 ++++---
 6 files changed, 92 insertions(+), 10 deletions(-)

-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 12f4948..aa90fff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+601.	[bug]*		jinmei, vorner
+	The "delete record" interface of the database based data source
+	was extended do that the parameter includes reversed name in
+	addition to the actual name.  This may help the underlying
+	accessor implementation if reversed names are more convenient
+	for the delete operation.  This was the case for the SQLite3
+	accessor implementation, and it now performs delete operations
+	much faster.  At a higher level, this means IXFR and DDNS Updates
+	to the sqlite3 database are no longer so slow on large zones as
+	they were before.
+	(Trac #2877, git 33bd949ac7288c61ed0a664b7329b50b36d180e5)
+
 600.	[bug]		tmark
 	Changed mysql_lease_mgr to set the SQL mode option to STRICT. This
 	causes mysql it to treat invalid input data as an error. Rather than
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index f6d8252..aa8c939 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -1644,17 +1644,23 @@ DatabaseUpdater::addRRset(const AbstractRRset& rrset) {
                 { cvtr.getName(), cvtr.getType(), cvtr.getTTL(), rdata_txt };
             accessor_->addRecordDiff(zone_id_, serial_.getValue(),
                                      Accessor::DIFF_ADD, journal);
+            LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ADDDIFF).
+                arg(cvtr.getName()).arg(cvtr.getType()).arg(rdata_txt);
         }
         if (nsec3_type) {
             const string nsec3_columns[Accessor::ADD_NSEC3_COLUMN_COUNT] =
                 { cvtr.getNSEC3Name(), cvtr.getTTL(), cvtr.getType(),
                   rdata_txt };
             accessor_->addNSEC3RecordToZone(nsec3_columns);
+            LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ADDNSEC3).
+                arg(cvtr.getNSEC3Name()).arg(rdata_txt);
         } else {
             const string columns[Accessor::ADD_COLUMN_COUNT] =
                 { cvtr.getName(), cvtr.getRevName(), cvtr.getTTL(),
                   cvtr.getType(), sigtype, rdata_txt };
             accessor_->addRecordToZone(columns);
+            LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ADDRR).
+                arg(cvtr.getName()).arg(cvtr.getType()).arg(rdata_txt);
         }
     }
 }
@@ -1698,14 +1704,21 @@ DatabaseUpdater::deleteRRset(const AbstractRRset& rrset) {
                 { cvtr.getName(), cvtr.getType(), cvtr.getTTL(), rdata_txt };
             accessor_->addRecordDiff(zone_id_, serial_.getValue(),
                                      Accessor::DIFF_DELETE, journal);
+            LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_DELETEDIFF).
+                arg(cvtr.getName()).arg(cvtr.getType()).arg(rdata_txt);
         }
         const string params[Accessor::DEL_PARAM_COUNT] =
             { nsec3_type ? cvtr.getNSEC3Name() : cvtr.getName(),
-              cvtr.getType(), rdata_txt };
+              cvtr.getType(), rdata_txt,
+              nsec3_type ? cvtr.getNSEC3Name() : cvtr.getRevName() };
         if (nsec3_type) {
             accessor_->deleteNSEC3RecordInZone(params);
+            LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_DELETENSEC3).
+                arg(cvtr.getNSEC3Name()).arg(rdata_txt);
         } else {
             accessor_->deleteRecordInZone(params);
+            LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_DELETERR).
+                arg(cvtr.getName()).arg(cvtr.getType()).arg(rdata_txt);
         }
     }
 }
diff --git a/src/lib/datasrc/database.h b/src/lib/datasrc/database.h
index 6505c9c..88a4140 100644
--- a/src/lib/datasrc/database.h
+++ b/src/lib/datasrc/database.h
@@ -122,12 +122,24 @@ public:
     /// Each derived implementation of deleteRecordInZone() should expect
     /// the "params" array to be filled with the values as described in this
     /// enumeration, in this order.
+    ///
+    /// DEL_RNAME is included in case the reversed from is more convenient
+    /// for the underlying implementation to identify the record to be
+    /// deleted (reversed names are generally easier to sort, which may help
+    /// perform the search faster).  It's up to the underlying implementation
+    /// which one (or both) it uses for the search.   DEL_NAME and DEL_RNAME
+    /// are mutually convertible with the understanding of DNS names, and
+    /// in that sense redundant.  But both are provided so the underlying
+    /// implementation doesn't have to deal with DNS level concepts.
     enum DeleteRecordParams {
         DEL_NAME = 0, ///< The owner name of the record (a domain name)
                       ///< or the hash label for deleteNSEC3RecordInZone()
         DEL_TYPE = 1, ///< The RRType of the record (A/NS/TXT etc.)
         DEL_RDATA = 2, ///< Full text representation of the record's RDATA
-        DEL_PARAM_COUNT = 3 ///< Number of parameters
+        DEL_RNAME = 3, ///< As DEL_NAME, but with the labels of domain name
+                       ///< in reverse order (eg. org.example.). With NSEC3,
+                       ///< it is the same as DEL_NAME.
+        DEL_PARAM_COUNT = 4 ///< Number of parameters
     };
 
     /// \brief Operation mode when adding a record diff.
diff --git a/src/lib/datasrc/datasrc_messages.mes b/src/lib/datasrc/datasrc_messages.mes
index 46d13a4..f2a7eca 100644
--- a/src/lib/datasrc/datasrc_messages.mes
+++ b/src/lib/datasrc/datasrc_messages.mes
@@ -83,11 +83,37 @@ with the content. The problem does not stop the new version from being used
 but it should still be checked and fixed. See the message to know what exactly
 is wrong with the data.
 
+% DATASRC_DATABASE_ADDDIFF updated diff table for add: %1 %2 %3
+Debug message. A difference record for adding a record to the zone is being
+appended to the difference table. The name, type and rdata of the record is
+logged.
+
+% DATASRC_DATABASE_ADDNSEC3 added NSEC3 RR: %1 %2
+Debug message. A new NSEC3 record is added to the table. The hash and the rdata
+is logged.
+
+% DATASRC_DATABASE_ADDRR added RR: %1 %2 %3
+Debug message. A new resource record is added to the table. The name, type and
+rdata is logged.
+
 % DATASRC_DATABASE_COVER_NSEC_UNSUPPORTED %1 doesn't support DNSSEC when asked for NSEC data covering %2
 The datasource tried to provide an NSEC proof that the named domain does not
 exist, but the database backend doesn't support DNSSEC. No proof is included
 in the answer as a result.
 
+% DATASRC_DATABASE_DELETEDIFF updated diff table for delete: %1 %2 %3
+Debug message. A difference record for removing a record from the zone is being
+appended to the difference table. The name, type and rdata of the record is
+logged.
+
+% DATASRC_DATABASE_DELETENSEC3 deleted NSEC3 RR: %1 %2
+Debug message. An NSEC3 record is removed from the table. The name, type and
+rdata is logged.
+
+% DATASRC_DATABASE_DELETERR deleted RR: %1 %2 %3
+Debug message. A resource record is removed from the table. The name, type and
+rdata is logged.
+
 % DATASRC_DATABASE_FINDNSEC3 Looking for NSEC3 for %1 in %2 mode
 Debug information. A search in an database data source for NSEC3 that
 matches or covers the given name is being started.
diff --git a/src/lib/datasrc/sqlite3_accessor.cc b/src/lib/datasrc/sqlite3_accessor.cc
index 11a5eb5..1653168 100644
--- a/src/lib/datasrc/sqlite3_accessor.cc
+++ b/src/lib/datasrc/sqlite3_accessor.cc
@@ -104,7 +104,9 @@ const char* const text_statements[NUM_STATEMENTS] = {
     "INSERT INTO records "      // ADD_RECORD
         "(zone_id, name, rname, ttl, rdtype, sigtype, rdata) "
         "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
-    "DELETE FROM records WHERE zone_id=?1 AND name=?2 " // DEL_RECORD
+    // DEL_RECORD:
+    // Delete based on the reverse name, as that one has an index.
+    "DELETE FROM records WHERE zone_id=?1 AND rname=?2 " // DEL_RECORD
         "AND rdtype=?3 AND rdata=?4",
 
     // ITERATE_RECORDS:
@@ -1295,8 +1297,16 @@ SQLite3Accessor::deleteRecordInZone(const string (&params)[DEL_PARAM_COUNT]) {
         isc_throw(DataSourceError, "deleting record in SQLite3 "
                   "data source without transaction");
     }
-    doUpdate<const string (&)[DEL_PARAM_COUNT]>(
-        *dbparameters_, DEL_RECORD, params, "delete record from zone");
+    // We don't pass all the parameters to the query, one name (reserve one
+    // in this case) is sufficient. Pass only the needed ones.
+    const size_t SQLITE3_DEL_PARAM_COUNT = DEL_PARAM_COUNT - 1;
+    const string sqlite3_params[SQLITE3_DEL_PARAM_COUNT] = {
+        params[DEL_RNAME],
+        params[DEL_TYPE],
+        params[DEL_RDATA]
+    };
+    doUpdate<const string (&)[SQLITE3_DEL_PARAM_COUNT]>(
+        *dbparameters_, DEL_RECORD, sqlite3_params, "delete record from zone");
 }
 
 void
@@ -1307,8 +1317,14 @@ SQLite3Accessor::deleteNSEC3RecordInZone(
         isc_throw(DataSourceError, "deleting NSEC3-related record in SQLite3 "
                   "data source without transaction");
     }
-    doUpdate<const string (&)[DEL_PARAM_COUNT]>(
-        *dbparameters_, DEL_NSEC3_RECORD, params,
+    const size_t SQLITE3_DEL_PARAM_COUNT = DEL_PARAM_COUNT - 1;
+    const string sqlite3_params[SQLITE3_DEL_PARAM_COUNT] = {
+        params[DEL_NAME],
+        params[DEL_TYPE],
+        params[DEL_RDATA]
+    };
+    doUpdate<const string (&)[SQLITE3_DEL_PARAM_COUNT]>(
+        *dbparameters_, DEL_NSEC3_RECORD, sqlite3_params,
         "delete NSEC3 record from zone");
 }
 
diff --git a/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc b/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc
index c263304..f8c1d78 100644
--- a/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc
+++ b/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc
@@ -806,7 +806,7 @@ const char* const new_data[] = {
 };
 const char* const deleted_data[] = {
     // Existing data to be removed commonly used by some of the tests below
-    "foo.bar.example.com.", "A", "192.0.2.1"
+    "foo.bar.example.com.", "A", "192.0.2.1", "com.example.bar.foo."
 };
 const char* const nsec3_data[DatabaseAccessor::ADD_NSEC3_COLUMN_COUNT] = {
     // example NSEC3 parameters.  Using "apex_hash" just as a convenient
@@ -823,7 +823,8 @@ const char* const nsec3_sig_data[DatabaseAccessor::ADD_NSEC3_COLUMN_COUNT] = {
 const char* const nsec3_deleted_data[] = {
     // Delete parameters for nsec3_data
     apex_hash, nsec3_data[DatabaseAccessor::ADD_NSEC3_TYPE],
-    nsec3_data[DatabaseAccessor::ADD_NSEC3_RDATA]
+    nsec3_data[DatabaseAccessor::ADD_NSEC3_RDATA],
+    apex_hash
 };
 
 class SQLite3Update : public SQLite3AccessorTest {
@@ -1222,6 +1223,7 @@ TEST_F(SQLite3Update, deleteNonexistent) {
     // Replace the name with a non existent one, then try to delete it.
     // nothing should happen.
     del_params[DatabaseAccessor::DEL_NAME] = "no-such-name.example.com.";
+    del_params[DatabaseAccessor::DEL_RNAME] = "com.example.no-such-name.";
     checkRecords(*accessor, zone_id, "no-such-name.example.com.",
                  empty_stored);
     accessor->deleteRecordInZone(del_params);
@@ -1535,7 +1537,7 @@ TEST_F(SQLite3Update, addDiffWithUpdate) {
     // the basic tests so far pass.  But we check it in case we miss something.
 
     const char* const old_a_record[] = {
-        "dns01.example.com.", "A", "192.0.2.1"
+        "dns01.example.com.", "A", "192.0.2.1", "com.example.dns01."
     };
     const char* const new_a_record[] = {
         "dns01.example.com.", "com.example.dns01.", "3600", "A", "",
@@ -1544,6 +1546,7 @@ TEST_F(SQLite3Update, addDiffWithUpdate) {
     const char* const old_soa_record[] = {
         "example.com.", "SOA",
         "ns.example.com. admin.example.com. 1234 3600 1800 2419200 7200",
+        "com.example."
     };
     const char* const new_soa_record[] = {
         "dns01.example.com.", "com.example.dns01.", "3600", "A", "",



More information about the bind10-changes mailing list