Add ledger.history.mismatch insight statistic

This commit is contained in:
Vinnie Falco
2014-08-25 17:13:05 -07:00
parent e024e7c2ec
commit e7cf3e8084
5 changed files with 45 additions and 11 deletions

View File

@@ -31,8 +31,11 @@ namespace ripple {
// FIXME: Need to clean up ledgers by index at some point
LedgerHistory::LedgerHistory ()
: m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE,
LedgerHistory::LedgerHistory (
beast::insight::Collector::ptr const& collector)
: collector_ (collector)
, mismatch_counter_ (collector->make_counter ("ledger.history", "mismatch"))
, m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE,
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
, m_consensus_validated ("ConsensusValidated", 64, 300,
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
@@ -158,14 +161,23 @@ void LedgerHistory::validatedLedger (Ledger::ref ledger)
if (entry->second != hash)
{
bool mismatch (false);
if (entry->second.isNonZero() && (entry->second != hash))
{
WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index << " validated:" << entry->second << " then:" << hash;
mismatch = true;
}
if (entry->first.isNonZero() && (entry->first != hash))
{
WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index << " built:" << entry->first << " validated:" << hash;
mismatch = true;
}
if (mismatch)
++mismatch_counter_;
entry->second = hash;
}
}

View File

@@ -20,6 +20,8 @@
#ifndef RIPPLE_LEDGERHISTORY_H
#define RIPPLE_LEDGERHISTORY_H
#include <beast/insight/Event.h>
namespace ripple {
// VFALCO TODO Rename to OldLedgers ?
@@ -28,7 +30,8 @@ namespace ripple {
class LedgerHistory : beast::LeakChecked <LedgerHistory>
{
public:
LedgerHistory ();
explicit
LedgerHistory (beast::insight::Collector::ptr const& collector);
/** Track a ledger
@return `true` if the ledger was already tracked
@@ -90,6 +93,9 @@ public:
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash);
private:
beast::insight::Collector::ptr collector_;
beast::insight::Counter mismatch_counter_;
typedef TaggedCache <LedgerHash, Ledger> LedgersByHash;
LedgersByHash m_ledgers_by_hash;

View File

@@ -18,8 +18,10 @@
//==============================================================================
#include <ripple/basics/containers/RangeSet.h>
#include <ripple/module/app/ledger/LedgerMaster.h>
#include <ripple/validators/Manager.h>
#include <cassert>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple {
@@ -77,9 +79,12 @@ public:
//--------------------------------------------------------------------------
explicit LedgerMasterImp (Stoppable& parent, beast::Journal journal)
LedgerMasterImp (Stoppable& parent,
beast::insight::Collector::ptr const& collector,
beast::Journal journal)
: LedgerMaster (parent)
, m_journal (journal)
, mLedgerHistory (collector)
, mHeldTransactions (uint256 ())
, mLedgerCleaner (LedgerCleaner::New(*this, deprecatedLogs().journal("LedgerCleaner")))
, mMinValidations (0)
@@ -1473,10 +1478,13 @@ bool LedgerMaster::shouldAcquire (
return ret;
}
LedgerMaster* LedgerMaster::New (Stoppable& parent, beast::Journal journal)
std::unique_ptr <LedgerMaster>
make_LedgerMaster (beast::Stoppable& parent,
beast::insight::Collector::ptr const& collector,
beast::Journal journal)
{
return new LedgerMasterImp (parent, journal);
return std::make_unique <LedgerMasterImp> (
parent, collector, journal);
}
} // ripple

View File

@@ -20,6 +20,11 @@
#ifndef RIPPLE_LEDGERMASTER_H_INCLUDED
#define RIPPLE_LEDGERMASTER_H_INCLUDED
// VFALCO TODO Make a header that forward declares Collector and
// its smart pointer container a-la boost.
//
#include <beast/insight/Collector.h>
namespace ripple {
// Tracks the current ledger and any ledgers in the process of closing
@@ -43,8 +48,6 @@ public:
typedef std::unique_lock <LockType> ScopedLockType;
typedef beast::GenericScopedUnlock <LockType> ScopedUnlockType;
static LedgerMaster* New (Stoppable& parent, beast::Journal journal);
virtual ~LedgerMaster () = 0;
virtual LedgerIndex getCurrentLedgerIndex () = 0;
@@ -147,6 +150,11 @@ public:
std::uint32_t ledgerHistory, std::uint32_t targetLedger);
};
std::unique_ptr <LedgerMaster>
make_LedgerMaster (beast::Stoppable& parent,
beast::insight::Collector::ptr const& collector,
beast::Journal journal);
} // ripple
#endif

View File

@@ -286,8 +286,8 @@ public:
, m_pathRequests (new PathRequests (
m_logs.journal("PathRequest"), m_collectorManager->collector ()))
, m_ledgerMaster (LedgerMaster::New (
*m_jobQueue, m_logs.journal("LedgerMaster")))
, m_ledgerMaster (make_LedgerMaster (*m_jobQueue,
m_collectorManager->collector (), m_logs.journal("LedgerMaster")))
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
// to dependencies in the destructor.