]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
sqlite3: make journal mode configurable; default to WAL
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 27 May 2019 12:26:16 +0000 (14:26 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 4 Jun 2019 10:09:05 +0000 (12:09 +0200)
docs/backends/bind.rst
docs/backends/generic-sqlite3.rst
docs/upgrading.rst
modules/bindbackend/bindbackend2.cc
modules/bindbackend/binddnssec.cc
modules/gsqlite3backend/gsqlite3backend.cc
pdns/pdnsutil.cc
pdns/ssqlite3.cc
pdns/ssqlite3.hh

index 5434f3ec58fd8aa9f8e95eaf252f292ab4de225b..df627bd04b9035bb251e124c3797b0627b4f7ec3 100644 (file)
@@ -80,6 +80,13 @@ during the zonetransfer.
    it will (silently) serve it without DNSSEC. This in turn results in
    serving the domain as bogus.
 
+.. _setting-bind-dnssec-db-journal-mode:
+
+``bind-dnssec-db-journal-mode``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SQLite3 journal mode to set. The default is WAL. Set to empty to leave the journal mode alone.
+
 .. _setting-bind-hybrid:
 
 ``bind-hybrid``
index b0e723aceea839688aed483f15a8f70a868d132c..9ac2a3cefddeecf03ec8fcda311aaaccfb248c4e 100644 (file)
@@ -68,6 +68,13 @@ gsqlite3 backend.
 
 Path to the SQLite3 database.
 
+.. _setting-gsqlite3-pragma-journal-mode:
+
+``gsqlite3-pragma-journal-mode``
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+SQLite3 journal mode to set. The default is WAL. Set to empty to leave the journal mode alone.
+
 .. _setting-gsqlite3-pragma-synchronous:
 
 ``gsqlite3-pragma-synchronous``
index b0b7ba64ff2e77b39c756fd8cf53e2c89caaad5f..622d1087d14358e7738bad550550a8b7386c8c5e 100644 (file)
@@ -12,6 +12,7 @@ upgrade notes if your version is older than 3.4.2.
 --------------
 
 - Superslave operation is no longer enabled by default, use :ref:`setting-superslave` to enable. This setting was called ``supermaster`` in some 4.2.0 prereleases.
+- The gsqlite3 backend, and the DNSSEC database for the BIND backend, have a new journal-mode setting. This setting defaults to `WAL <https://www.sqlite.org/wal.html>`_; older versions of PowerDNS did not set the journal mode, which means they used the SQLite default of DELETE.
 
 4.1.0 to 4.1.1
 --------------
index 69d0450fc9999bbb8e2ecdc36a77ce9f85e97482..e0dffb0dc59e0c9d587d18bc45b036ffd7776257 100644 (file)
@@ -1352,6 +1352,7 @@ class Bind2Factory : public BackendFactory
          declare(suffix,"supermasters","List of IP-addresses of supermasters","");
          declare(suffix,"supermaster-destdir","Destination directory for newly added slave zones",::arg()["config-dir"]);
          declare(suffix,"dnssec-db","Filename to store & access our DNSSEC metadatabase, empty for none", "");         
+         declare(suffix,"dnssec-db-journal-mode","SQLite3 journal mode", "WAL");
          declare(suffix,"hybrid","Store DNSSEC metadata in other backend","no");
       }
 
index f254ec5c7a445556db20dbc641039458e50bc08b..93996982e96534df5fa5f35ffb9960ec3d77afe5 100644 (file)
@@ -96,7 +96,7 @@ void Bind2Backend::setupDNSSEC()
   if(getArg("dnssec-db").empty() || d_hybrid)
     return;
   try {
-    d_dnssecdb = shared_ptr<SSQLite3>(new SSQLite3(getArg("dnssec-db")));
+    d_dnssecdb = shared_ptr<SSQLite3>(new SSQLite3(getArg("dnssec-db"), getArg("dnssec-db-journal-mode")));
     setupStatements();
   }
   catch(SSqlException& se) {
index 28eddf2aa0826c1c0f53777aa62bf20083eb2779..a188fc655e32cd54bc61ef50f74bb6be1ff5cc67 100644 (file)
@@ -43,7 +43,7 @@ gSQLite3Backend::gSQLite3Backend( const std::string & mode, const std::string &
 {
   try
   {
-    SSQLite3 *ptr = new SSQLite3( getArg( "database" ));
+    SSQLite3 *ptr = new SSQLite3( getArg( "database" ), getArg( "pragma-journal-mode") );
     setDB(ptr);
     if(!getArg("pragma-synchronous").empty()) {
       ptr->execute("PRAGMA synchronous="+getArg("pragma-synchronous"));
@@ -77,6 +77,7 @@ public:
     declare(suffix, "database", "Filename of the SQLite3 database", "powerdns.sqlite");
     declare(suffix, "pragma-synchronous", "Set this to 0 for blazing speed", "");
     declare(suffix, "pragma-foreign-keys", "Enable foreign key constraints", "no" );
+    declare(suffix, "pragma-journal-mode", "SQLite3 journal mode", "WAL");
 
     declare(suffix, "dnssec", "Enable DNSSEC processing","no");
 
index 5abce3b4db3f851bf6da0a7c521c2ea2da705409..8b39b07a55f1dff8a7b2e2ba8f548838442a01fb 100644 (file)
@@ -2081,7 +2081,7 @@ try
       return 0;
     }
     try {
-      SSQLite3 db(cmds[1], true); // create=ok
+      SSQLite3 db(cmds[1], "", true); // create=ok
       vector<string> statements;
       stringtok(statements, sqlCreate, ";");
       for(const string& statement :  statements) {
index 8adeb28d24350cee7c0d20c622af31575d41ec40..eb7075388d1af4f7a925f61d8460b6bdc731455b 100644 (file)
@@ -180,7 +180,7 @@ private:
 };
 
 // Constructor.
-SSQLite3::SSQLite3( const std::string & database, bool creat )
+SSQLite3::SSQLite3( const std::string & database, const std::string & journalmode, bool creat )
 {
   if (access( database.c_str(), F_OK ) == -1){
     if (!creat)
@@ -195,6 +195,9 @@ SSQLite3::SSQLite3( const std::string & database, bool creat )
   m_dolog = 0;
   m_in_transaction = false;
   sqlite3_busy_handler(m_pDB, busyHandler, 0);
+
+  if(journalmode.length())
+    execute("PRAGMA journal_mode="+journalmode);
 }
 
 void SSQLite3::setLog(bool state)
index 9b02caba5431ac91b37577c85601f115bbebd820..5768337b20396bb3224d34ab75c7d52b5de5871c 100644 (file)
@@ -37,7 +37,7 @@ private:
 protected:
 public:
   //! Constructor.
-  SSQLite3( const std::string & database, bool creat=false );
+  SSQLite3( const std::string & database, const std::string & journalmode, bool creat=false);
 
   //! Destructor.
   ~SSQLite3();