From 62f0a9a902031d172e03e8caaaad013a1798749f Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 23 Jan 2024 19:15:30 +0200 Subject: [PATCH] lib/mu-xapian-db: handle exception with dec_transaction_level I.e., do our book-keeping beforehand. --- lib/mu-xapian-db.hh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/mu-xapian-db.hh b/lib/mu-xapian-db.hh index 91de8764..62c5789e 100644 --- a/lib/mu-xapian-db.hh +++ b/lib/mu-xapian-db.hh @@ -447,12 +447,14 @@ public: mu_critical("cannot dec transaction-level)"); throw std::runtime_error("cannot dec transactions"); } - if (tx_level_ == 1) {// need to commit the Xapian transaction? - mu_debug("committing {} changes", changes_); - wdb().commit_transaction(); - changes_ = 0; - } + --tx_level_; + if (tx_level_ == 0) {// need to commit the Xapian transaction? + mu_debug("committing {} changes", changes_); + changes_ = 0; + wdb().commit_transaction(); + } + mu_debug("dec'd tx level to {}", tx_level_); }); }