From 2b95a657091f0be90891f197dd24f9f25c0c5510 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 23 May 2019 22:43:41 -0700 Subject: [PATCH] ircd::db: Fix various error handling around db::init. --- ircd/db.cc | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/ircd/db.cc b/ircd/db.cc index 3d952e795..cc2aaf5b9 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -138,6 +138,7 @@ ircd::db::abi_version_str // ircd::db::init::init() +try { init_compressions(); init_directory(); @@ -145,6 +146,16 @@ ircd::db::init::init() init_test_hw_crc32(); request.add(request_pool_size); } +catch(const std::exception &e) +{ + log::critical + { + log, "Cannot start database system :%s", + e.what() + }; + + throw; +} ircd::db::init::~init() noexcept @@ -203,9 +214,9 @@ try } catch(const fs::error &e) { - log::critical + log::error { - log, "Cannot start database system: %s", e.what() + log, "Database directory error: %s", e.what() }; throw; @@ -263,6 +274,7 @@ namespace rocksdb::crc32c void ircd::db::init_test_hw_crc32() +try { const auto supported_str { @@ -282,19 +294,28 @@ ircd::db::init_test_hw_crc32() log, "crc32c hardware acceleration is not available on this platform." }; } +catch(const std::exception &e) +{ + log::error + { + log, "Failed to test crc32c hardware acceleration support :%s", + e.what() + }; +} decltype(ircd::db::compressions) ircd::db::compressions; void ircd::db::init_compressions() +try { auto supported { rocksdb::GetSupportedCompressions() }; - for(const rocksdb::CompressionType &type : supported) + for(const rocksdb::CompressionType &type : supported) try { auto &string(compressions.at(uint(type))); throw_on_error @@ -302,6 +323,15 @@ ircd::db::init_compressions() rocksdb::GetStringFromCompressionType(&string, type) }; } + catch(const std::exception &e) + { + log::error + { + log, "Failed to identify compression type:%u :%s", + uint(type), + e.what() + }; + } if(supported.empty()) log::warning @@ -310,6 +340,16 @@ ircd::db::init_compressions() " This is probably not what you want." }; } +catch(const std::exception &e) +{ + log::error + { + log, "Failed to initialize database compressions :%s", + e.what() + }; + + throw; +} /////////////////////////////////////////////////////////////////////////////// //