From a39970ae3b8fdce30d5f8c5d400007ee6feb910b Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Sun, 17 Jul 2022 21:06:12 +0200 Subject: [PATCH] auth: fix Duplicate RO transaction --- modules/lmdbbackend/lmdbbackend.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) 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; } -- 2.47.2