From 1ed63335664bcaf5598bb52ce8a223cb76785461 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Wed, 2 Sep 2015 13:57:55 -0500 Subject: [PATCH] storage_proxy: log failed attempts at communicating If an exception happens in the query path, we'll never know about it. They are currently being ignored. Investigating this, I found out that this is because the readers in storage_proxy.cc handles them - but don't log they anywhere. This patch introduces such logging. the error() function takes an sstring not an exception_ptr: this is so we can reuse it in the future to also log problems from other hosts (currently not done). We have a separate helper to extract the message from the current exception before we pass it to error() Fixes #110 Signed-off-by: Glauber Costa --- service/storage_proxy.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/service/storage_proxy.cc b/service/storage_proxy.cc index 1753ce97a8..2e442e0b48 100644 --- a/service/storage_proxy.cc +++ b/service/storage_proxy.cc @@ -1229,8 +1229,9 @@ public: future<> done() { return _done_promise.get_future(); } - virtual void error(gms::inet_address ep) { - // do nothing for now, request will timeout eventually + virtual void error(gms::inet_address ep, sstring why) { + // do nothing other than log for now, request will timeout eventually + logger.error("Exception when communicating with {}: {}", ep, why); } }; @@ -1431,6 +1432,16 @@ public: virtual ~abstract_read_executor() {}; protected: + static sstring error_sstring(std::exception_ptr eptr) { + try { + std::rethrow_exception(eptr); + } catch(std::exception& e) { + return sstring(e.what()); + } catch(...) { + return sstring("Unknown exception"); + } + } + future>> make_mutation_data_request(lw_shared_ptr cmd, gms::inet_address ep) { if (is_me(ep)) { return get_local_storage_proxy().query_mutations_locally(cmd, _partition_range); @@ -1465,7 +1476,7 @@ protected: try { resolver->add_mutate_data(ep, f.get0()); } catch(...) { - resolver->error(ep); + resolver->error(ep, error_sstring(std::current_exception())); } }); }); @@ -1476,7 +1487,7 @@ protected: try { resolver->add_data(ep, f.get0()); } catch(...) { - resolver->error(ep); + resolver->error(ep, error_sstring(std::current_exception())); } }); }); @@ -1487,7 +1498,7 @@ protected: try { resolver->add_digest(ep, f.get0()); } catch(...) { - resolver->error(ep); + resolver->error(ep, error_sstring(std::current_exception())); } }); });