]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: fix Duplicate RO transaction
authorKees Monshouwer <mind04@monshouwer.org>
Sun, 17 Jul 2022 19:06:12 +0000 (21:06 +0200)
committermind04 <mind04@monshouwer.org>
Sun, 17 Jul 2022 22:06:30 +0000 (00:06 +0200)
modules/lmdbbackend/lmdbbackend.cc

index c0857b03ebf6728fb4472dadb36ac18a37d6bf77..fa9cd527d619d2e5b7ee50ae6572eea893aff68c 100644 (file)
@@ -671,6 +671,15 @@ bool LMDBBackend::upgradeToSchemav3()
 
 bool LMDBBackend::deleteDomain(const DNSName& domain)
 {
+  if (!d_rwtxn) {
+    throw DBException(std::string(__PRETTY_FUNCTION__) + " called without a transaction");
+  }
+
+  int transactionDomainId = d_transactiondomainid;
+  DNSName transactionDomain = d_transactiondomain;
+
+  abortTransaction();
+
   uint32_t id;
 
   { // get domain id
@@ -680,13 +689,7 @@ bool LMDBBackend::deleteDomain(const DNSName& domain)
     id = txn.get<0>(domain, di);
   }
 
-  if (!d_rwtxn) {
-    throw DBException(std::string(__PRETTY_FUNCTION__) + " called without a transaction");
-  }
-  if (d_transactiondomainid != id) {
-    commitTransaction();
-    startTransaction(domain);
-  }
+  startTransaction(domain, id);
 
   { // Remove metadata
     auto txn = d_tmeta->getRWTransaction();
@@ -710,14 +713,15 @@ bool LMDBBackend::deleteDomain(const DNSName& domain)
     txn.commit();
   }
 
+  // Remove records
+  commitTransaction();
+  startTransaction(transactionDomain, transactionDomainId);
+
   // Remove zone
   auto txn = d_tdomains->getRWTransaction();
   txn.del(id);
   txn.commit();
 
-  // Remove records
-  deleteDomainRecords(*d_rwtxn, id);
-
   return true;
 }