Skip to content

Commit

Permalink
reactor: add abandoned failed futures counter
Browse files Browse the repository at this point in the history
Count the instances of futures containing an unhandled exception being
destroyed. We are already logging these instances as they most likely
point to bugs in the application. However logging doesn't provide enough
visibility as one has to be actively monitor the logs to observe this
happening. Provide a counter to allow better observability.
  • Loading branch information
denesb committed Dec 5, 2019
1 parent 830a2ea commit febaec8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/seastar/core/reactor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ private:
io_stats _io_stats;
uint64_t _fsyncs = 0;
uint64_t _cxx_exceptions = 0;
uint64_t _abandoned_failed_futures = 0;
struct task_queue {
explicit task_queue(unsigned id, sstring name, float shares);
int64_t _vruntime = 0;
Expand Down Expand Up @@ -605,6 +606,7 @@ public:
std::chrono::nanoseconds total_steal_time();

const io_stats& get_io_stats() const { return _io_stats; }
uint64_t abandoned_failed_futures() const { return _abandoned_failed_futures; }
#ifdef HAVE_OSV
void timer_thread_func();
void set_timer(sched::timer &tmr, s64 t);
Expand Down Expand Up @@ -655,6 +657,7 @@ private:
friend class scheduling_group;
friend void add_to_flush_poller(output_stream<char>* os);
friend int ::_Unwind_RaiseException(struct _Unwind_Exception *h);
friend void report_failed_future(const std::exception_ptr& eptr) noexcept;
metrics::metric_groups _metric_groups;
friend future<scheduling_group> create_scheduling_group(sstring name, float shares);
friend future<> seastar::destroy_scheduling_group(scheduling_group);
Expand Down
2 changes: 2 additions & 0 deletions src/core/reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,7 @@ void reactor::register_metrics() {
sm::make_derive("logging_failures", [] { return logging_failures; }, sm::description("Total number of logging failures")),
// total_operations value:DERIVE:0:U
sm::make_derive("cpp_exceptions", _cxx_exceptions, sm::description("Total number of C++ exceptions")),
sm::make_derive("abandoned_failed_futures", _abandoned_failed_futures, sm::description("Total number of abandoned failed futures, futures destroyed while still containing an exception")),
});

auto ioq_group = sm::label("mountpoint");
Expand Down Expand Up @@ -3870,6 +3871,7 @@ void engine_exit(std::exception_ptr eptr) {
}

void report_failed_future(const std::exception_ptr& eptr) noexcept {
++engine()._abandoned_failed_futures;
seastar_logger.warn("Exceptional future ignored: {}, backtrace: {}", eptr, current_backtrace());
}

Expand Down

0 comments on commit febaec8

Please sign in to comment.