From f927094726d6757e6abccc71c353738687f1080e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 24 May 2018 17:47:09 +0200 Subject: We can't recover from not being able to open the database. We'll only end up with defunctional processes that may or may not do anything useful. --- common/storage_lmdb.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index b60f707..f7d38a1 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp @@ -955,14 +955,16 @@ public: if (!(env = sEnvironments.value(fullPath))) { int rc = 0; if ((rc = mdb_env_create(&env))) { - SinkWarningCtx(logCtx) << "mdb_env_create: " << rc << " " << mdb_strerror(rc); - qCritical() << "mdb_env_create: " << rc << " " << mdb_strerror(rc); + SinkErrorCtx(logCtx) << "mdb_env_create: " << rc << " " << mdb_strerror(rc); env = nullptr; + throw std::runtime_error("Fatal error while creating db."); } else { //Limit large enough to accomodate all our named dbs. This only starts to matter if the number gets large, otherwise it's just a bunch of extra entries in the main table. mdb_env_set_maxdbs(env, 50); if (const int rc = mdb_env_set_mapsize(env, mapsize())) { - SinkWarningCtx(logCtx) << "mdb_env_set_mapsize: " << rc << ":" << mdb_strerror(rc); + SinkErrorCtx(logCtx) << "mdb_env_set_mapsize: " << rc << ":" << mdb_strerror(rc); + Q_ASSERT(false); + throw std::runtime_error("Fatal error while creating db."); } const bool readOnly = (mode == ReadOnly); unsigned int flags = MDB_NOTLS; @@ -973,7 +975,9 @@ public: if (readOnly) { SinkLogCtx(logCtx) << "Tried to open non-existing db: " << fullPath; } else { - SinkWarningCtx(logCtx) << "mdb_env_open: " << rc << ":" << mdb_strerror(rc); + SinkErrorCtx(logCtx) << "mdb_env_open: " << rc << ":" << mdb_strerror(rc); + Q_ASSERT(false); + throw std::runtime_error("Fatal error while creating db."); } mdb_env_close(env); env = 0; -- cgit v1.2.3