]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add lmdb-lightning-stream option
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 28 Apr 2023 11:40:27 +0000 (13:40 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 28 Apr 2023 11:40:27 +0000 (13:40 +0200)
docs/backends/lmdb.rst
ext/lmdb-safe/lmdb-safe.cc
ext/lmdb-safe/lmdb-safe.hh
modules/lmdbbackend/lmdbbackend.cc

index b3c48f83c240a82c4c1ca274a1c1963f87ba9ff4..df52719cf19b8ae74ac2697a9b6a435c6a04ccee 100644 (file)
@@ -121,6 +121,17 @@ Defaults to 100 on 32 bit systems, and 16000 on 64 bit systems.
 Instead of deleting items from the database, flag them as deleted in the item's `Lightning Stream <https://doc.powerdns.com/lightningstream>`_ header.
 Only enable this if you are using Lightning Stream.
 
+``lmdb-lightning-stream``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+  .. versionadded:: 4.8.0
+
+Run in Lightning Stream compatible mode. This:
+
+* forces ``flag-deleted`` on
+* forces ``random-ids`` on
+* handles duplicate entries in databases that can result from domains being added on two Lightning Stream nodes at the same time
+
 LMDB Structure
 --------------
 
index 33c3d4568acdd585482e2778c6bbba1783a3dc10..4aa6d313a7d8e3ee70786ba3d175d941b4b76563 100644 (file)
@@ -69,6 +69,7 @@ namespace LMDBLS {
   }
 
   bool s_flag_deleted{false};
+  bool s_handle_dups{false};
 }
 
 #endif /* #ifndef DNSDIST */
index 2d5983be6761194454bc9c3603c756d0c295f276..79c3c82dd3386b6bf62c8804ca6adf2bd1510816 100644 (file)
@@ -156,6 +156,7 @@ namespace LMDBLS {
   bool LSisDeleted(std::string_view val);
 
   extern bool s_flag_deleted;
+  extern bool s_handle_dups;
 }
 
 #undef _LMDB_SAFE_BSWAP64MAYBE
index 749b4acb2baf6b75bbecc5f14fd9a62c4e794966..05a64a230f30f9a83675f950674d9a76e75d00f4 100644 (file)
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include "ext/lmdb-safe/lmdb-safe.hh"
 #include <lmdb.h>
 #include <utility>
 #ifdef HAVE_CONFIG_H
@@ -665,6 +666,13 @@ LMDBBackend::LMDBBackend(const std::string& suffix)
   }
 
   LMDBLS::s_flag_deleted = mustDo("flag-deleted");
+  LMDBLS::s_handle_dups = false;
+
+  if (mustDo("lightning-stream")) {
+    d_random_ids = true;
+    LMDBLS::s_flag_deleted = true;
+    LMDBLS::s_handle_dups = true;
+  }
 
   bool opened = false;
 
@@ -2562,6 +2570,7 @@ public:
     declare(suffix, "random-ids", "Numeric IDs inside the database are generated randomly instead of sequentially", "no");
     declare(suffix, "map-size", "LMDB map size in megabytes", (sizeof(void*) == 4) ? "100" : "16000");
     declare(suffix, "flag-deleted", "Flag entries on deletion instead of deleting them", "no");
+    declare(suffix, "lightning-stream", "Run in Lightning Stream compatible mode", "no");
   }
   DNSBackend* make(const string& suffix = "") override
   {