From d79d770958363e187d87e14541d3e0f02d46a274 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 12 May 2022 08:50:20 +0300 Subject: [PATCH] store: improve error handling Detect store-lock --- lib/mu-server.cc | 3 +-- lib/mu-store.cc | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/mu-server.cc b/lib/mu-server.cc index 8ee380eb..b5fc59d7 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -586,8 +586,7 @@ docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100) throw Error(Error::Code::Store, &gerr, "failed to run msgid-query"); else if (res->empty()) throw Error(Error::Code::NotFound, - "could not find message(s) for msgid %s", - msgid.c_str()); + "could not find message(s) for msgid %s", msgid.c_str()); std::vector docids{}; for (auto&& mi : *res) diff --git a/lib/mu-store.cc b/lib/mu-store.cc index 2f756c59..550d3ce2 100644 --- a/lib/mu-store.cc +++ b/lib/mu-store.cc @@ -113,11 +113,9 @@ struct Store::Private { std::unique_ptr make_xapian_db(const std::string db_path, XapianOpts opts) try { - /* we do our own flushing, set Xapian's internal one as the * backstop*/ - g_setenv("XAPIAN_FLUSH_THRESHOLD", - format("%zu", properties_.batch_size + 100).c_str(), 1); + g_setenv("XAPIAN_FLUSH_THRESHOLD", "500000", 1); switch (opts) { case XapianOpts::ReadOnly: @@ -132,6 +130,11 @@ struct Store::Private { throw std::logic_error("invalid xapian options"); } + } catch (const Xapian::DatabaseLockError& xde) { + throw Mu::Error(Error::Code::StoreLock, + "failed to lock store @ %s: %s", + db_path.c_str(), + xde.get_msg().c_str()); } catch (const Xapian::DatabaseError& xde) { throw Mu::Error(Error::Code::Store, "failed to open store @ %s: %s",