diff --git a/include/xrpl/nodestore/DatabaseRotating.h b/include/xrpl/nodestore/DatabaseRotating.h index 5872e553d6..dc8e27ee55 100644 --- a/include/xrpl/nodestore/DatabaseRotating.h +++ b/include/xrpl/nodestore/DatabaseRotating.h @@ -55,6 +55,9 @@ public: setRotationInFlight(LedgerIndex inFlight) = 0; virtual LedgerIndex getRotationInFlight() const = 0; + + virtual std::uint64_t + getDuplicationCount() const = 0; }; } // namespace xrpl::NodeStore diff --git a/include/xrpl/nodestore/detail/DatabaseRotatingImp.h b/include/xrpl/nodestore/detail/DatabaseRotatingImp.h index 2bec58c674..4a2518dd05 100644 --- a/include/xrpl/nodestore/detail/DatabaseRotatingImp.h +++ b/include/xrpl/nodestore/detail/DatabaseRotatingImp.h @@ -76,6 +76,9 @@ public: LedgerIndex getRotationInFlight() const override; + std::uint64_t + getDuplicationCount() const override; + private: std::shared_ptr writableBackend_; std::shared_ptr archiveBackend_; @@ -93,6 +96,9 @@ private: std::atomic rotationInFlight_{0}; std::atomic copyForwardCount_{0}; std::atomic copyRejectCount_{0}; + // Duplication count tracks the number of nodes that are directly duplicated because they're in + // the target ledger or cache. + std::atomic duplicationCount_{0}; std::shared_ptr fetchNodeObject(uint256 const& hash, std::uint32_t, FetchReport& fetchReport, bool duplicate) diff --git a/src/libxrpl/nodestore/DatabaseRotatingImp.cpp b/src/libxrpl/nodestore/DatabaseRotatingImp.cpp index 0a5850d52b..83a371e69d 100644 --- a/src/libxrpl/nodestore/DatabaseRotatingImp.cpp +++ b/src/libxrpl/nodestore/DatabaseRotatingImp.cpp @@ -56,6 +56,7 @@ DatabaseRotatingImp::rotate( std::shared_ptr oldArchiveBackend; std::uint64_t copyForwards = 0; std::uint64_t copyRejects = 0; + std::uint64_t duplications = 0; { std::scoped_lock const lock(mutex_); @@ -69,6 +70,7 @@ DatabaseRotatingImp::rotate( copyForwards = copyForwardCount_.exchange(0, std::memory_order_relaxed); copyRejects = copyRejectCount_.exchange(0, std::memory_order_relaxed); + duplications = duplicationCount_.exchange(0, std::memory_order_relaxed); } if (copyForwards > 0 || copyRejects > 0) @@ -78,6 +80,11 @@ DatabaseRotatingImp::rotate( "during the rotation window. Rejected " << copyRejects; } + if (duplications > 0) + { + JLOG(j_.warn()) << "Rotating: duplicated " << duplications + << " nodes into the writable backend for the current validated ledger."; + } f(newWritableBackendName, newArchiveBackendName); } @@ -95,6 +102,12 @@ DatabaseRotatingImp::getRotationInFlight() const return rotationInFlight_.load(std::memory_order_acquire); } +std::uint64_t +DatabaseRotatingImp::getDuplicationCount() const +{ + return duplicationCount_.load(std::memory_order_acquire); +} + std::string DatabaseRotatingImp::getName() const { @@ -214,7 +227,11 @@ DatabaseRotatingImp::fetchNodeObject( writable = writableBackend_; } - if (!duplicate) + if (duplicate) + { + duplicationCount_.fetch_add(1, std::memory_order_relaxed); + } + else { JLOG(j_.debug()) << "Rotating: copy node for ledger " << ledgerSeq << " from archive to writable backend: " << hash; diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index 77863619f8..3580f03580 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -451,7 +451,8 @@ SHAMapStoreImp::run() return; // Only log if we completed without a "health" abort JLOG(journal_.debug()) - << "copied ledger " << validatedSeq << " nodecount " << nodeCount; + << "copied ledger " << validatedSeq << " duplicated " + << dbRotating_->getDuplicationCount() << " / " << nodeCount << " nodes"; JLOG(journal_.debug()) << "freshening caches"; freshenCaches();