Skip to content

Commit

Permalink
Warn about large backlog of notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 4, 2025
1 parent 1b98927 commit 1785fcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ enum class detail

// http_callbacks
block_confirmed,
large_backlog,

_last // Must be the last enum
};
Expand Down
10 changes: 10 additions & 0 deletions nano/node/rpc_callbacks.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/lib/block_type.hpp>
#include <nano/lib/interval.hpp>
#include <nano/node/node.hpp>
#include <nano/node/rpc_callbacks.hpp>
#include <nano/secure/ledger.hpp>
Expand Down Expand Up @@ -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] () {
Expand Down

0 comments on commit 1785fcf

Please sign in to comment.