From 22d2501360a0c11d9de8f03cfb5ef8ac74de14c1 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Sun, 12 Jul 2026 17:30:06 -0400 Subject: [PATCH] Speed up rotation when disconnected, log resurrected fields - Logs whether any recovered nodes are in the TreeNodeCache. - Adds a special case to healthWait() to not pause when the server is DISCONNECTED. --- src/xrpld/app/misc/SHAMapStoreImp.cpp | 31 ++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index fc214058a5..f5d83e5d7e 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -16,8 +16,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -280,8 +280,13 @@ SHAMapStoreImp::copyNode(std::uint64_t& nodeCount, SHAMapTreeNode const& node) Serializer s; node.serializeWithPrefix(s); dbRotating_->store(NodeObjectType::AccountNode, std::move(s.modData()), hash, 0); - JLOG(journal_.warn()) << "copyNode: re-stored node missing from both backends, hash=" - << hash << " type=" << static_cast(node.getType()); + { + auto const& cached = treeNodeCache_->fetch(hash); + JLOG(journal_.warn()) << "copyNode: re-stored node missing from both backends, hash=" + << hash << " type=" << static_cast(node.getType()) + << ". Node is " << (cached ? "" : "not ") + << "in the tree node cache"; + } } if ((++nodeCount % checkHealthInterval_) == 0u) { @@ -683,7 +688,6 @@ SHAMapStoreImp::healthWait() numMissing = lowerBound == 0 ? 0 : ledgerMaster_->missingFromCompleteLedgerRange(lowerBound, index); }; - // Tracked server status properties LedgerIndex index = 0; std::chrono::seconds age; @@ -702,7 +706,24 @@ SHAMapStoreImp::healthWait() readServerStatus(index, age, mode, numMissing, lowerBound, unlock); } - while (!stop_ && (mode != OperatingMode::FULL || age > ageThreshold || numMissing > 0)) + + auto healthy = [&]() { + // Special case: If the server is disconnected, it's not doing any ledger I/O, because + // it's focused on trying to get peers. A disconnected state is should never be caused by + // the activity of the server. It's usually limited to hardware or connectivity issues. Take + // advantage of that to run as much rotation I/O as possible before it comes back online. + if (mode == OperatingMode::DISCONNECTED) + return true; + if (age > ageThreshold) + return false; + if (numMissing > 0) + return false; + if (mode != OperatingMode::FULL) + return false; + return true; + }; + + while (!stop_ && !healthy()) { // this value shouldn't change, so grab it while we have the // lock