From 1785fcf02896b37e40cc0ff476d14916251e841b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:48:55 +0100 Subject: [PATCH] Warn about large backlog of notifications --- nano/lib/stats_enums.hpp | 1 + nano/node/rpc_callbacks.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/nano/lib/stats_enums.hpp b/nano/lib/stats_enums.hpp index 630e0d1ea0..752b49081a 100644 --- a/nano/lib/stats_enums.hpp +++ b/nano/lib/stats_enums.hpp @@ -638,6 +638,7 @@ enum class detail // http_callbacks block_confirmed, + large_backlog, _last // Must be the last enum }; diff --git a/nano/node/rpc_callbacks.cpp b/nano/node/rpc_callbacks.cpp index cb1a0be4f2..9fa05802c5 100644 --- a/nano/node/rpc_callbacks.cpp +++ b/nano/node/rpc_callbacks.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -51,6 +52,15 @@ void nano::http_callbacks::setup_callbacks () { stats.inc (nano::stat::type::http_callbacks_notified, nano::stat::detail::block_confirmed); + constexpr size_t warning_threshold = 10000; + static nano::interval warning_interval; + + if (workers.queued_tasks () > warning_threshold && warning_interval.elapsed (15s)) + { + stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::large_backlog); + logger.warn (nano::log::type::http_callbacks, "Backlog of {} http callback notifications to process", workers.queued_tasks ()); + } + // Post callback processing to worker thread // Safe to capture 'this' by reference as workers are stopped before this component destruction workers.post ([this, block_a, account_a, amount_a, is_state_send_a, is_state_epoch_a] () {