summaryrefslogtreecommitdiffstats
path: root/common/storage_lmdb.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-05-24 17:47:09 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-05-24 17:47:09 +0200
commitf927094726d6757e6abccc71c353738687f1080e (patch)
tree47ba376564f3690bc75966606b1ee272b723a385 /common/storage_lmdb.cpp
parentc095e82143fd16c84263d990b96590b3b0d12a78 (diff)
downloadsink-f927094726d6757e6abccc71c353738687f1080e.tar.gz
sink-f927094726d6757e6abccc71c353738687f1080e.zip
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.
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r--common/storage_lmdb.cpp12
1 files 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:
955 if (!(env = sEnvironments.value(fullPath))) { 955 if (!(env = sEnvironments.value(fullPath))) {
956 int rc = 0; 956 int rc = 0;
957 if ((rc = mdb_env_create(&env))) { 957 if ((rc = mdb_env_create(&env))) {
958 SinkWarningCtx(logCtx) << "mdb_env_create: " << rc << " " << mdb_strerror(rc); 958 SinkErrorCtx(logCtx) << "mdb_env_create: " << rc << " " << mdb_strerror(rc);
959 qCritical() << "mdb_env_create: " << rc << " " << mdb_strerror(rc);
960 env = nullptr; 959 env = nullptr;
960 throw std::runtime_error("Fatal error while creating db.");
961 } else { 961 } else {
962 //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. 962 //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.
963 mdb_env_set_maxdbs(env, 50); 963 mdb_env_set_maxdbs(env, 50);
964 if (const int rc = mdb_env_set_mapsize(env, mapsize())) { 964 if (const int rc = mdb_env_set_mapsize(env, mapsize())) {
965 SinkWarningCtx(logCtx) << "mdb_env_set_mapsize: " << rc << ":" << mdb_strerror(rc); 965 SinkErrorCtx(logCtx) << "mdb_env_set_mapsize: " << rc << ":" << mdb_strerror(rc);
966 Q_ASSERT(false);
967 throw std::runtime_error("Fatal error while creating db.");
966 } 968 }
967 const bool readOnly = (mode == ReadOnly); 969 const bool readOnly = (mode == ReadOnly);
968 unsigned int flags = MDB_NOTLS; 970 unsigned int flags = MDB_NOTLS;
@@ -973,7 +975,9 @@ public:
973 if (readOnly) { 975 if (readOnly) {
974 SinkLogCtx(logCtx) << "Tried to open non-existing db: " << fullPath; 976 SinkLogCtx(logCtx) << "Tried to open non-existing db: " << fullPath;
975 } else { 977 } else {
976 SinkWarningCtx(logCtx) << "mdb_env_open: " << rc << ":" << mdb_strerror(rc); 978 SinkErrorCtx(logCtx) << "mdb_env_open: " << rc << ":" << mdb_strerror(rc);
979 Q_ASSERT(false);
980 throw std::runtime_error("Fatal error while creating db.");
977 } 981 }
978 mdb_env_close(env); 982 mdb_env_close(env);
979 env = 0; 983 env = 0;