mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
better logging
This commit is contained in:
@@ -1700,7 +1700,7 @@ public:
|
||||
void
|
||||
run() override
|
||||
{
|
||||
bool log = false;
|
||||
bool log = true;
|
||||
testConfig(log);
|
||||
testInitialRound(log);
|
||||
testPeerUnsquelchedTooSoon(log);
|
||||
|
||||
@@ -40,7 +40,7 @@ static constexpr auto MAX_UNSQUELCH_EXPIRE_DEFAULT = std::chrono::seconds{600};
|
||||
static constexpr auto SQUELCH_PER_PEER = std::chrono::seconds(10);
|
||||
static constexpr auto MAX_UNSQUELCH_EXPIRE_PEERS = std::chrono::seconds{3600};
|
||||
// No message received threshold before identifying a peer as idled
|
||||
static constexpr auto IDLED = std::chrono::seconds{8};
|
||||
static constexpr auto IDLED = std::chrono::seconds{5};
|
||||
// Message count threshold to start selecting peers as the source
|
||||
// of messages from the validator. We add peers who reach
|
||||
// MIN_MESSAGE_THRESHOLD to considered pool once MAX_SELECTED_PEERS
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
@@ -259,6 +261,7 @@ class Slot final
|
||||
time_point expire; // squelch expiration time
|
||||
time_point lastMessage; // time last message received
|
||||
std::size_t timesSelected; // number of times the peer was selected
|
||||
std::size_t timesCloseToThreshold;
|
||||
};
|
||||
|
||||
std::unordered_map<id_t, PeerInfo> peers_; // peer's data
|
||||
@@ -330,7 +333,8 @@ Slot<clock_type>::update(
|
||||
.count = 0,
|
||||
.expire = now,
|
||||
.lastMessage = now,
|
||||
.timesSelected = 0}));
|
||||
.timesSelected = 0,
|
||||
.timesCloseToThreshold = 0}));
|
||||
initCounting();
|
||||
return;
|
||||
}
|
||||
@@ -354,6 +358,9 @@ Slot<clock_type>::update(
|
||||
<< duration_cast<milliseconds>(now - peer.lastMessage).count()
|
||||
<< " pool " << considered_.size() << " threshold " << reachedThreshold_;
|
||||
|
||||
if (now - peer.lastMessage - IDLED <= milliseconds{500})
|
||||
++peer.timesCloseToThreshold;
|
||||
|
||||
peer.lastMessage = now;
|
||||
|
||||
// report if we received a message from a squelched peer
|
||||
@@ -379,6 +386,16 @@ Slot<clock_type>::update(
|
||||
|
||||
if (reachedThreshold_ == maxSelectedPeers_)
|
||||
{
|
||||
for (auto const& [id, info] : peers_)
|
||||
{
|
||||
if (info.state == PeerState::Selected &&
|
||||
info.count < MIN_MESSAGE_THRESHOLD)
|
||||
{
|
||||
JLOG(journal_.debug())
|
||||
<< "update: previously selected peer " << id
|
||||
<< " failed to reach a threshold with: " << info.count;
|
||||
}
|
||||
}
|
||||
// Randomly select maxSelectedPeers_ peers from considered.
|
||||
// Exclude peers that have been idling > IDLED -
|
||||
// it's possible that deleteIdlePeer() has not been called yet.
|
||||
@@ -440,6 +457,11 @@ Slot<clock_type>::update(
|
||||
|
||||
else if (v.state != PeerState::Squelched)
|
||||
{
|
||||
if (v.state == PeerState::Selected)
|
||||
{
|
||||
JLOG(journal_.debug())
|
||||
<< "squelching previously selected peer";
|
||||
}
|
||||
if (journal_.trace())
|
||||
str << k << " ";
|
||||
v.state = PeerState::Squelched;
|
||||
@@ -540,6 +562,7 @@ Slot<clock_type>::onWrite(beast::PropertyStream::Map& stream) const
|
||||
item["lastMessage"] =
|
||||
duration_cast<std::chrono::seconds>(now - info.lastMessage).count();
|
||||
item["timesSelected"] = info.timesSelected;
|
||||
item["timesCloseToThreshold"] = info.timesCloseToThreshold;
|
||||
item["state"] = to_string(info.state);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user