Skip to content

Commit 79bd3d9

Browse files
Merge #6311: fix: 2 follow-ups for PeriodicStats
802efc5 fix: update DEFAULT_STATSD_HOST (UdjinM6) 44d7806 fix: use correct rpc interruption point in `PeriodicStats` (UdjinM6) Pull request description: ## Issue being fixed or feature implemented - 5c2c2b3: dash-qt with stats enabled crashes - b92ce3d: help text for `-statshost` is misleading ## What was done? ## How Has This Been Tested? ## Breaking Changes ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: utACK 802efc5 Tree-SHA512: 093229a96e726dc30c8aef210046bebaef040179785fd8be20de5052d766b361426f18f41338ef059997e820645faa7fba424f056be2f6454ca3190f8c3c0906
2 parents a76395c + 802efc5 commit 79bd3d9

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/init.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,15 @@ static void StartupNotify(const ArgsManager& args)
837837
}
838838
#endif
839839

840-
static void PeriodicStats(ArgsManager& args, ChainstateManager& chainman, const CTxMemPool& mempool)
840+
static void PeriodicStats(NodeContext& node)
841841
{
842842
assert(::g_stats_client->active());
843+
const ArgsManager& args = *Assert(node.args);
844+
ChainstateManager& chainman = *Assert(node.chainman);
845+
const CTxMemPool& mempool = *Assert(node.mempool);
843846
CCoinsStats stats{CoinStatsHashType::NONE};
844847
chainman.ActiveChainstate().ForceFlushStateToDisk();
845-
if (WITH_LOCK(cs_main, return GetUTXOStats(&chainman.ActiveChainstate().CoinsDB(), std::ref(chainman.m_blockman), stats, RpcInterruptionPoint, chainman.ActiveChain().Tip()))) {
848+
if (WITH_LOCK(cs_main, return GetUTXOStats(&chainman.ActiveChainstate().CoinsDB(), chainman.m_blockman, stats, node.rpc_interruption_point, chainman.ActiveChain().Tip()))) {
846849
::g_stats_client->gauge("utxoset.tx", stats.nTransactions, 1.0f);
847850
::g_stats_client->gauge("utxoset.txOutputs", stats.nTransactionOutputs, 1.0f);
848851
::g_stats_client->gauge("utxoset.dbSizeBytes", stats.nDiskSize, 1.0f);
@@ -2299,7 +2302,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
22992302

23002303
if (::g_stats_client->active()) {
23012304
int nStatsPeriod = std::min(std::max((int)args.GetArg("-statsperiod", DEFAULT_STATSD_PERIOD), MIN_STATSD_PERIOD), MAX_STATSD_PERIOD);
2302-
node.scheduler->scheduleEvery(std::bind(&PeriodicStats, std::ref(*node.args), std::ref(chainman), std::cref(*node.mempool)), std::chrono::seconds{nStatsPeriod});
2305+
node.scheduler->scheduleEvery(std::bind(&PeriodicStats, std::ref(node)), std::chrono::seconds{nStatsPeriod});
23032306
}
23042307

23052308
// ********************************************************* Step 11: import blocks

src/stats/client.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ std::unique_ptr<StatsdClient> g_stats_client;
3434
std::unique_ptr<StatsdClient> InitStatsClient(const ArgsManager& args)
3535
{
3636
auto is_enabled = args.GetBoolArg("-statsenabled", /*fDefault=*/false);
37-
auto host = args.GetArg("-statshost", /*fDefault=*/"");
37+
auto host = args.GetArg("-statshost", /*fDefault=*/DEFAULT_STATSD_HOST);
3838

3939
if (is_enabled && host.empty()) {
4040
// Stats are enabled but host has not been specified, then use
41-
// default host. This is to preserve old behavior.
42-
host = DEFAULT_STATSD_HOST;
41+
// default legacy host. This is to preserve old behavior.
42+
host = "127.0.0.1";
4343
} else if (!host.empty()) {
4444
// Host is specified but stats are not explcitly enabled. Assume
4545
// that if a host has been specified, we want stats enabled. This

src/stats/client.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RawSender;
1919
/** Default port used to connect to a Statsd server */
2020
static constexpr uint16_t DEFAULT_STATSD_PORT{8125};
2121
/** Default host assumed to be running a Statsd server */
22-
static const std::string DEFAULT_STATSD_HOST{"127.0.0.1"};
22+
static const std::string DEFAULT_STATSD_HOST{""};
2323
/** Default prefix prepended to Statsd message keys */
2424
static const std::string DEFAULT_STATSD_PREFIX{""};
2525
/** Default suffix appended to Statsd message keys */

0 commit comments

Comments
 (0)