don't create strands for cache download. output cache info in server_info

This commit is contained in:
CJ Cobb
2022-03-16 10:40:47 -04:00
committed by CJ Cobb
parent 15505905cb
commit 16e3c87dcc
5 changed files with 13 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
#include <backend/SimpleCache.h>
namespace Backend {
uint32_t
SimpleCache::latestLedgerSequence()
SimpleCache::latestLedgerSequence() const
{
std::shared_lock lck{mtx_};
return latestSeq_;
@@ -91,12 +91,12 @@ SimpleCache::setFull()
}
bool
SimpleCache::isFull()
SimpleCache::isFull() const
{
return full_;
}
size_t
SimpleCache::size()
SimpleCache::size() const
{
std::shared_lock lck{mtx_};
return map_.size();

View File

@@ -49,14 +49,14 @@ public:
setFull();
uint32_t
latestLedgerSequence();
latestLedgerSequence() const;
// whether the cache has all data for the most recent ledger
bool
isFull();
isFull() const;
size_t
size();
size() const;
};
} // namespace Backend

View File

@@ -937,9 +937,8 @@ ReportingETL::loadCache(uint32_t seq)
{
std::optional<ripple::uint256> start = cursors[i];
std::optional<ripple::uint256> end = cursors[i + 1];
cacheDownloadStrands_.emplace_back(ioContext_);
boost::asio::spawn(
cacheDownloadStrands_.back(),
ioContext_,
[this, seq, start, end, numRemaining](
boost::asio::yield_context yield) {
std::optional<ripple::uint256> cursor = start;
@@ -948,7 +947,7 @@ ReportingETL::loadCache(uint32_t seq)
auto res =
Backend::retryOnTimeout([this, seq, &cursor, &yield]() {
return backend_->fetchLedgerPage(
cursor, seq, 256, yield);
cursor, seq, 256, false, yield);
});
backend_->cache().update(res.objects, seq, true);
if (!res.cursor || (end && *(res.cursor) > *end))

View File

@@ -67,8 +67,6 @@ private:
/// ledgers are published in order
boost::asio::io_context::strand publishStrand_;
std::vector<boost::asio::io_context::strand> cacheDownloadStrands_;
/// Mechanism for communicating with ETL sources. ETLLoadBalancer wraps an
/// arbitrary number of ETL sources and load balances ETL requests across
/// those sources.

View File

@@ -29,6 +29,11 @@ doServerInfo(Context const& context)
info["counters"] = boost::json::object{};
info["counters"].as_object()["rpc"] = context.counters.report();
}
auto& cache = (response["cache"] = boost::json::object{}).as_object();
cache["size"] = context.backend->cache().size();
cache["is_full"] = context.backend->cache().isFull();
cache["latest_ledger_seq"] =
context.backend->cache().latestLedgerSequence();
auto serverInfoRippled = context.balancer->forwardToRippled(
context.params, context.clientIp, context.yield);