database/storage_proxy: Use "is_timeout_exception" instead of catch match

Might miss cases otherwise.

v2: Fix broken control flow
v3: Avoid throw - use make_exception_future instead.
This commit is contained in:
Calle Wilund
2022-01-17 12:12:59 +00:00
parent 97bb1be6f7
commit 868b572ec8
2 changed files with 4 additions and 10 deletions

View File

@@ -1824,13 +1824,11 @@ Future database::update_write_metrics(Future&& f) {
return f.then_wrapped([this, s = _stats] (auto f) {
if (f.failed()) {
++s->total_writes_failed;
try {
f.get();
} catch (const timed_out_error&) {
auto ep = f.get_exception();
if (is_timeout_exception(ep)) {
++s->total_writes_timedout;
throw;
}
assert(0 && "should not reach");
return futurize<Future>::make_exception_future(std::move(ep));
}
++s->total_writes;
return f;

View File

@@ -4999,14 +4999,10 @@ void storage_proxy::init_messaging_service(shared_ptr<migration_manager> mm) {
});
}).handle_exception([reply_to, shard, &p, &errors] (std::exception_ptr eptr) {
seastar::log_level l = seastar::log_level::warn;
try {
std::rethrow_exception(eptr);
} catch (timed_out_error&) {
if (is_timeout_exception(eptr)) {
// ignore timeouts so that logs are not flooded.
// database total_writes_timedout counter was incremented.
l = seastar::log_level::debug;
} catch (...) {
// ignore
}
slogger.log(l, "Failed to apply mutation from {}#{}: {}", reply_to, shard, eptr);
errors++;