From a1fe4858b544aa21748533c3156affcf9822b374 Mon Sep 17 00:00:00 2001 From: CJ Cobb Date: Thu, 3 Mar 2022 15:17:38 -0500 Subject: [PATCH] Only launch thread to download cache once. Fix parent ledger check --- src/etl/ReportingETL.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/etl/ReportingETL.cpp b/src/etl/ReportingETL.cpp index 6a5d3e38b..3ad2ec9b1 100644 --- a/src/etl/ReportingETL.cpp +++ b/src/etl/ReportingETL.cpp @@ -549,7 +549,7 @@ ReportingETL::runETLPipeline(uint32_t startSequence, int numExtractors) writing_ = true; auto rng = backend_->hardFetchLedgerRangeNoThrow(); - if (!rng || rng->maxSequence != startSequence - 1) + if (!rng || rng->maxSequence < startSequence - 1) { assert(false); throw std::runtime_error("runETLPipeline: parent ledger is null"); @@ -828,6 +828,15 @@ ReportingETL::monitor() { } uint32_t nextSequence = latestSequence.value() + 1; + if (!backend_->cache().isFull()) + { + std::thread t{[this, latestSequence]() { + BOOST_LOG_TRIVIAL(info) << "Loading cache"; + loadBalancer_->loadInitialLedger(*latestSequence, true); + backend_->cache().setFull(); + }}; + t.detach(); + } BOOST_LOG_TRIVIAL(debug) << __func__ << " : " @@ -840,15 +849,6 @@ ReportingETL::monitor() << "Ledger with sequence = " << nextSequence << " has been validated by the network. " << "Attempting to find in database and publish"; - if (!backend_->cache().isFull()) - { - std::thread t{[this, latestSequence]() { - BOOST_LOG_TRIVIAL(info) << "Loading cache"; - loadBalancer_->loadInitialLedger(*latestSequence, true); - backend_->cache().setFull(); - }}; - t.detach(); - } // Attempt to take over responsibility of ETL writer after 2 failed // attempts to publish the ledger. publishLedger() fails if the // ledger that has been validated by the network is not found in the