From 5f17e59d6bd45af65d59bd48bc6cc6a9b78128a5 Mon Sep 17 00:00:00 2001 From: CJ Cobb Date: Fri, 24 Sep 2021 14:01:55 -0400 Subject: [PATCH] allow publishLedger to run forever --- src/etl/ReportingETL.cpp | 25 +++++++------------------ src/etl/ReportingETL.h | 2 +- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/etl/ReportingETL.cpp b/src/etl/ReportingETL.cpp index fceeb617..c9d9ce23 100644 --- a/src/etl/ReportingETL.cpp +++ b/src/etl/ReportingETL.cpp @@ -169,7 +169,9 @@ ReportingETL::publishLedger(ripple::LedgerInfo const& lgrInfo) } bool -ReportingETL::publishLedger(uint32_t ledgerSequence, uint32_t maxAttempts) +ReportingETL::publishLedger( + uint32_t ledgerSequence, + std::optional maxAttempts) { BOOST_LOG_TRIVIAL(info) << __func__ << " : " @@ -189,25 +191,13 @@ ReportingETL::publishLedger(uint32_t ledgerSequence, uint32_t maxAttempts) << ledgerSequence; // We try maxAttempts times to publish the ledger, waiting one // second in between each attempt. - // If the ledger is not present in the database after - // maxAttempts, we attempt to take over as the writer. If the - // takeover fails, doContinuousETL will return, and this node - // will go back to publishing. If the node is in strict read - // only mode, we simply skip publishing this ledger and return - // false indicating the publish failed - if (numAttempts >= maxAttempts) + if (maxAttempts && numAttempts >= maxAttempts) { BOOST_LOG_TRIVIAL(debug) << __func__ << " : " << "Failed to publish ledger after " << numAttempts << " attempts."; - if (!readOnly_) - { - BOOST_LOG_TRIVIAL(info) - << __func__ << " : " - << "Attempting to become ETL writer"; - return false; - } + return false; } std::this_thread::sleep_for(std::chrono::seconds(1)); ++numAttempts; @@ -620,7 +610,7 @@ ReportingETL::monitor() << "Ledger with sequence = " << nextSequence << " has been validated by the network. " << "Attempting to find in database and publish"; - // Attempt to take over responsibility of ETL writer after 10 failed + // 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 // database after the specified number of attempts. publishLedger() @@ -671,11 +661,10 @@ ReportingETL::monitorReadOnly() if (!mostRecent) return; uint32_t sequence = *mostRecent; - bool success = true; while (!stopping_ && networkValidatedLedgers_->waitUntilValidatedByNetwork(sequence)) { - publishLedger(sequence, 30); + publishLedger(sequence, {}); ++sequence; } } diff --git a/src/etl/ReportingETL.h b/src/etl/ReportingETL.h index 9a36de3a..10b9c879 100644 --- a/src/etl/ReportingETL.h +++ b/src/etl/ReportingETL.h @@ -222,7 +222,7 @@ private: /// from the database. 1 attempt per second /// @return whether the ledger was found in the database and published bool - publishLedger(uint32_t ledgerSequence, uint32_t maxAttempts = 10); + publishLedger(uint32_t ledgerSequence, std::optional maxAttempts); /// Publish the passed in ledger /// @param ledger the ledger to publish