From: Kees Monshouwer Date: Sun, 17 Jul 2022 19:06:12 +0000 (+0200) Subject: auth: fix Duplicate RO transaction X-Git-Tag: auth-4.8.0-alpha0~7^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a39970ae3b8fdce30d5f8c5d400007ee6feb910b;p=thirdparty%2Fpdns.git auth: fix Duplicate RO transaction --- diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index c0857b03eb..fa9cd527d6 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -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; }