Skip to content

Commit

Permalink
2.1.0-rc1-debugrelay-11:
Browse files Browse the repository at this point in the history
Logs for finding new ledgers to publish.
  • Loading branch information
mtrippled committed Apr 2, 2024
1 parent 5ec513a commit f937790
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
42 changes: 40 additions & 2 deletions src/ripple/app/ledger/impl/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,24 +1363,36 @@ std::vector<std::shared_ptr<Ledger const>>
LedgerMaster::findNewLedgersToPublish(
std::unique_lock<std::recursive_mutex>& sl)
{
std::stringstream ss;
ss << "findNewLedgersToPublish ";

std::vector<std::shared_ptr<Ledger const>> ret;

JLOG(m_journal.trace()) << "findNewLedgersToPublish<";

ss << " mValidLedger.empty()? " << mValidLedger.empty();
// No valid ledger, nothing to do
if (mValidLedger.empty())
{
JLOG(m_journal.trace()) << "No valid journal, nothing to publish.";
ss << " returning";
JLOG(m_journal.debug()) << ss.str();
return {};
}

ss << " mPubLedger? " << mPubLedger;
if (!mPubLedger)
{
JLOG(m_journal.info())
<< "First published ledger will be " << mValidLedgerSeq;
ss << " first published ledger will be mValidLedgerSeq " << mValidLedgerSeq
<< " mValidLedger.get() " << mValidLedger.get();
JLOG(m_journal.debug()) << ss.str();
return {mValidLedger.get()};
}

ss << " mValidLedgerSeq,mPubLedgerSeq,MAX_LEDGER_GAP: "
<< mValidLedgerSeq << ',' << mPubLedgerSeq << ',' << MAX_LEDGER_GAP;
if (mValidLedgerSeq > (mPubLedgerSeq + MAX_LEDGER_GAP))
{
JLOG(m_journal.warn()) << "Gap in validated ledger stream "
Expand All @@ -1390,13 +1402,17 @@ LedgerMaster::findNewLedgersToPublish(
ret.push_back(valLedger);
setPubLedger(valLedger);
app_.getOrderBookDB().setup(valLedger);
ss << " returning valid ledger " << valLedger;
JLOG(m_journal.debug()) << ss.str();

return {valLedger};
}

if (mValidLedgerSeq <= mPubLedgerSeq)
{
JLOG(m_journal.trace()) << "No valid journal, nothing to publish.";
ss << " mValidLedgerSeq <= mPubLedgerSeq, nothing to puslish";
JLOG(m_journal.debug()) << ss.str();
return {};
}

Expand All @@ -1406,11 +1422,14 @@ LedgerMaster::findNewLedgersToPublish(
auto valLedger = mValidLedger.get();
std::uint32_t valSeq = valLedger->info().seq;

ss << "LEDGER REPLAY configured? " << app_.config().LEDGER_REPLAY << ", ";
ss << " now iterating through ledgers from " << pubSeq << " to " << valSeq << " inclusive: ";
ScopedUnlock sul{sl};
try
{
for (std::uint32_t seq = pubSeq; seq <= valSeq; ++seq)
{
ss << " seq " << seq;
JLOG(m_journal.trace())
<< "Trying to fetch/publish valid ledger " << seq;

Expand All @@ -1420,16 +1439,21 @@ LedgerMaster::findNewLedgersToPublish(
// VFALCO TODO Restructure this code so that zero is not
// used.
if (!hash)
{
ss << " no hash setting to beast::zero ";
hash = beast::zero; // kludge
}
if (seq == valSeq)
{
// We need to publish the ledger we just fully validated
ss << " publish the ledger we just fully validated (seq == valSeq) ";
ledger = valLedger;
}
else if (hash->isZero())
{
JLOG(m_journal.fatal()) << "Ledger: " << valSeq
<< " does not have hash for " << seq;
ss << " hash is zero, no hash available ";
assert(false);
}
else
Expand All @@ -1439,20 +1463,29 @@ LedgerMaster::findNewLedgersToPublish(

if (!app_.config().LEDGER_REPLAY)
{
ss << " acqCount,ledger_fetch_size_: " << acqCount + 1
<< ',' << ledger_fetch_size_ << " ";
// Can we try to acquire the ledger we need?
if (!ledger && (++acqCount < ledger_fetch_size_))
{
ss << "acquire() " << seq << " ";
ledger = app_.getInboundLedgers().acquire(
*hash, seq, InboundLedger::Reason::GENERIC);
}
}

// Did we acquire the next ledger we need to publish?
ss << " we have ledger? " << ledger << " it's seq,pubSeq: "
<< ledger->info().seq << ',' << pubSeq << " ";
if (ledger && (ledger->info().seq == pubSeq))
{
ss << " yes, set it validated, add to return vector and increment pubSeq to " << pubSeq + 1 << " ";
ledger->setValidated();
ret.push_back(ledger);
++pubSeq;
}
}
ss << ". ready to publish " << ret.size() << " ledgers. ";

JLOG(m_journal.trace())
<< "ready to publish " << ret.size() << " ledgers.";
Expand All @@ -1462,10 +1495,12 @@ LedgerMaster::findNewLedgersToPublish(
JLOG(m_journal.error())
<< "Exception while trying to find ledgers to publish: "
<< ex.what();
ss << " exception while trying to find ledgers to publish: " << ex.what() << " ";
}

if (app_.config().LEDGER_REPLAY)
{
ss << " narrow down and attempt to replay ledgers. ";
/* Narrow down the gap of ledgers, and try to replay them.
* When replaying a ledger gap, if the local node has
* the start ledger, it saves an expensive InboundLedger
Expand All @@ -1486,7 +1521,8 @@ LedgerMaster::findNewLedgersToPublish(
{
auto numberLedgers =
finishLedger->seq() - startLedger->seq() + 1;
JLOG(m_journal.debug())
// JLOG(m_journal.debug())
ss
<< "Publish LedgerReplays " << numberLedgers
<< " ledgers, from seq=" << startLedger->info().seq << ", "
<< startLedger->info().hash
Expand All @@ -1501,6 +1537,7 @@ LedgerMaster::findNewLedgersToPublish(
}
}

ss << ss.str();
return ret;
}

Expand Down Expand Up @@ -2125,9 +2162,10 @@ LedgerMaster::doAdvance(std::unique_lock<std::recursive_mutex>& sl)
JLOG(m_journal.debug()) << "doAdvance aka tryAdvance number of "
<< "ledgers to publish " << pubLedgers.size();
std::stringstream ss;
ss << "doAdvance aka tryAdvance ";
if (pubLedgers.empty())
{
ss << "doAdvance aka tryAdvance no ledgers to publish. Figuring out why. ";
ss << "no ledgers to publish. Figuring out why. ";
ss << "standalone_: " << standalone_
<< " isLoadedLocal: " << app_.getFeeTrack().isLoadedLocal()
<< " getJobCount(jtPUBOLDLEDGER): " << app_.getJobQueue().getJobCount(jtPUBOLDLEDGER)
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/impl/BuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace BuildInfo {
// and follow the format described at http://semver.org/
//------------------------------------------------------------------------------
// clang-format off
char const* const versionString = "2.1.0-rc1-debugrelay-10"
char const* const versionString = "2.1.0-rc1-debugrelay-11"
// clang-format on

#if defined(DEBUG) || defined(SANITIZER)
Expand Down

0 comments on commit f937790

Please sign in to comment.