From: Peter van Dijk Date: Mon, 27 May 2019 12:26:16 +0000 (+0200) Subject: sqlite3: make journal mode configurable; default to WAL X-Git-Tag: dnsdist-1.4.0-beta1~5^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=367f9b409eb7faa06d5f37534e8e5ae699f9e5c4;p=pdns sqlite3: make journal mode configurable; default to WAL --- diff --git a/docs/backends/bind.rst b/docs/backends/bind.rst index 5434f3ec5..df627bd04 100644 --- a/docs/backends/bind.rst +++ b/docs/backends/bind.rst @@ -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`` diff --git a/docs/backends/generic-sqlite3.rst b/docs/backends/generic-sqlite3.rst index b0e723ace..9ac2a3cef 100644 --- a/docs/backends/generic-sqlite3.rst +++ b/docs/backends/generic-sqlite3.rst @@ -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`` diff --git a/docs/upgrading.rst b/docs/upgrading.rst index b0b7ba64f..622d1087d 100644 --- a/docs/upgrading.rst +++ b/docs/upgrading.rst @@ -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 `_; 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 -------------- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 69d0450fc..e0dffb0dc 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -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"); } diff --git a/modules/bindbackend/binddnssec.cc b/modules/bindbackend/binddnssec.cc index f254ec5c7..93996982e 100644 --- a/modules/bindbackend/binddnssec.cc +++ b/modules/bindbackend/binddnssec.cc @@ -96,7 +96,7 @@ void Bind2Backend::setupDNSSEC() if(getArg("dnssec-db").empty() || d_hybrid) return; try { - d_dnssecdb = shared_ptr(new SSQLite3(getArg("dnssec-db"))); + d_dnssecdb = shared_ptr(new SSQLite3(getArg("dnssec-db"), getArg("dnssec-db-journal-mode"))); setupStatements(); } catch(SSqlException& se) { diff --git a/modules/gsqlite3backend/gsqlite3backend.cc b/modules/gsqlite3backend/gsqlite3backend.cc index 28eddf2aa..a188fc655 100644 --- a/modules/gsqlite3backend/gsqlite3backend.cc +++ b/modules/gsqlite3backend/gsqlite3backend.cc @@ -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"); diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 5abce3b4d..8b39b07a5 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -2081,7 +2081,7 @@ try return 0; } try { - SSQLite3 db(cmds[1], true); // create=ok + SSQLite3 db(cmds[1], "", true); // create=ok vector statements; stringtok(statements, sqlCreate, ";"); for(const string& statement : statements) { diff --git a/pdns/ssqlite3.cc b/pdns/ssqlite3.cc index 8adeb28d2..eb7075388 100644 --- a/pdns/ssqlite3.cc +++ b/pdns/ssqlite3.cc @@ -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) diff --git a/pdns/ssqlite3.hh b/pdns/ssqlite3.hh index 9b02caba5..5768337b2 100644 --- a/pdns/ssqlite3.hh +++ b/pdns/ssqlite3.hh @@ -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();