From 9b5e4f8d489ff31a8f34095d65f256ecbdf3c266 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 27 Feb 2020 14:49:26 -0800 Subject: [PATCH] ircd::db: Improve error propagation and reporting on _seek(). --- ircd/db.cc | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/ircd/db.cc b/ircd/db.cc index 2bfaf19ba..4618c89ea 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -7472,7 +7472,7 @@ ircd::db::throw_on_error::throw_on_error(const rocksdb::Status &status) throw not_found{}; #ifdef RB_DEBUG - case Status::kCorruption: + //case Status::kCorruption: case Status::kNotSupported: case Status::kInvalidArgument: debugtrap(); @@ -7730,6 +7730,7 @@ ircd::db::_seek(database::column &c, const string_view &p, const rocksdb::ReadOptions &opts, rocksdb::Iterator &it) +try { const ctx::uninterruptible ui; @@ -7756,12 +7757,28 @@ ircd::db::_seek(database::column &c, return valid(it); } +catch(const error &e) +{ + const database &d(*c.d); + log::critical + { + log, "[%s][%s] %lu:%lu SEEK key :%s", + name(d), + name(c), + sequence(d), + sequence(opts.snapshot), + e.what(), + }; + + throw; +} bool ircd::db::_seek(database::column &c, const pos &p, const rocksdb::ReadOptions &opts, rocksdb::Iterator &it) +try { const ctx::stack_usage_assertion sua; @@ -7793,6 +7810,22 @@ ircd::db::_seek(database::column &c, return valid(it); } +catch(const error &e) +{ + const database &d(*c.d); + log::critical + { + log, "[%s][%s] %lu:%lu SEEK %s :%s", + name(d), + name(c), + sequence(d), + sequence(opts.snapshot), + reflect(p), + e.what(), + }; + + throw; +} /// Seek to entry NOT GREATER THAN key. That is, equal to or less than key rocksdb::Iterator & @@ -7924,22 +7957,7 @@ ircd::db::valid(const rocksdb::Iterator &it) case Status::kOk: case Status::kNotFound: case Status::kIncomplete: - break; - - case Status::kCorruption: - { - const db::error error - { - it.status() - }; - - log::critical - { - log, "%s", error.what() - }; - - [[fallthrough]]; - } + return it.Valid(); default: throw_on_error @@ -7949,8 +7967,6 @@ ircd::db::valid(const rocksdb::Iterator &it) __builtin_unreachable(); } - - return it.Valid(); } //