Rename SHAMapStoreImp::stopping() to healthWait()

This commit is contained in:
Scott Schurr
2022-05-02 18:09:29 -07:00
committed by manojsdoshi
parent 3726f8bf31
commit 7e9e9104ea
2 changed files with 24 additions and 24 deletions

View File

@@ -269,7 +269,7 @@ SHAMapStoreImp::copyNode(std::uint64_t& nodeCount, SHAMapTreeNode const& node)
true); true);
if (!(++nodeCount % checkHealthInterval_)) if (!(++nodeCount % checkHealthInterval_))
{ {
if (stopping()) if (healthWait() == stopping)
return false; return false;
} }
@@ -327,7 +327,7 @@ SHAMapStoreImp::run()
bool const readyToRotate = bool const readyToRotate =
validatedSeq >= lastRotated + deleteInterval_ && validatedSeq >= lastRotated + deleteInterval_ &&
canDelete_ >= lastRotated - 1 && !stopping(); canDelete_ >= lastRotated - 1 && healthWait() == keepGoing;
// Make sure we don't delete ledgers currently being // Make sure we don't delete ledgers currently being
// imported into the ShardStore // imported into the ShardStore
@@ -359,7 +359,7 @@ SHAMapStoreImp::run()
<< ledgerMaster_->getValidatedLedgerAge().count() << 's'; << ledgerMaster_->getValidatedLedgerAge().count() << 's';
clearPrior(lastRotated); clearPrior(lastRotated);
if (stopping()) if (healthWait() == stopping)
return; return;
JLOG(journal_.debug()) << "copying ledger " << validatedSeq; JLOG(journal_.debug()) << "copying ledger " << validatedSeq;
@@ -382,7 +382,7 @@ SHAMapStoreImp::run()
continue; continue;
} }
if (stopping()) if (healthWait() == stopping)
return; return;
// Only log if we completed without a "health" abort // Only log if we completed without a "health" abort
JLOG(journal_.debug()) << "copied ledger " << validatedSeq JLOG(journal_.debug()) << "copied ledger " << validatedSeq
@@ -390,7 +390,7 @@ SHAMapStoreImp::run()
JLOG(journal_.debug()) << "freshening caches"; JLOG(journal_.debug()) << "freshening caches";
freshenCaches(); freshenCaches();
if (stopping()) if (healthWait() == stopping)
return; return;
// Only log if we completed without a "health" abort // Only log if we completed without a "health" abort
JLOG(journal_.debug()) << validatedSeq << " freshened caches"; JLOG(journal_.debug()) << validatedSeq << " freshened caches";
@@ -401,7 +401,7 @@ SHAMapStoreImp::run()
<< validatedSeq << " new backend " << newBackend->getName(); << validatedSeq << " new backend " << newBackend->getName();
clearCaches(validatedSeq); clearCaches(validatedSeq);
if (stopping()) if (healthWait() == stopping)
return; return;
lastRotated = validatedSeq; lastRotated = validatedSeq;
@@ -566,7 +566,7 @@ SHAMapStoreImp::clearSql(
min = *m; min = *m;
} }
if (min > lastRotated || stopping()) if (min > lastRotated || healthWait() == stopping)
return; return;
if (min == lastRotated) if (min == lastRotated)
{ {
@@ -587,11 +587,11 @@ SHAMapStoreImp::clearSql(
JLOG(journal_.trace()) JLOG(journal_.trace())
<< "End: Delete up to " << deleteBatch_ << " rows with LedgerSeq < " << "End: Delete up to " << deleteBatch_ << " rows with LedgerSeq < "
<< min << " from: " << TableName; << min << " from: " << TableName;
if (stopping()) if (healthWait() == stopping)
return; return;
if (min < lastRotated) if (min < lastRotated)
std::this_thread::sleep_for(backOff_); std::this_thread::sleep_for(backOff_);
if (stopping()) if (healthWait() == stopping)
return; return;
} }
JLOG(journal_.debug()) << "finished deleting from: " << TableName; JLOG(journal_.debug()) << "finished deleting from: " << TableName;
@@ -631,7 +631,7 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated)
ledgerMaster_->clearPriorLedgers(lastRotated); ledgerMaster_->clearPriorLedgers(lastRotated);
JLOG(journal_.trace()) << "End: Clear internal ledgers up to " JLOG(journal_.trace()) << "End: Clear internal ledgers up to "
<< lastRotated; << lastRotated;
if (stopping()) if (healthWait() == stopping)
return; return;
SQLiteDatabase* const db = SQLiteDatabase* const db =
@@ -645,7 +645,7 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated)
"Ledgers", "Ledgers",
[db]() -> std::optional<LedgerIndex> { return db->getMinLedgerSeq(); }, [db]() -> std::optional<LedgerIndex> { return db->getMinLedgerSeq(); },
[db](LedgerIndex min) -> void { db->deleteBeforeLedgerSeq(min); }); [db](LedgerIndex min) -> void { db->deleteBeforeLedgerSeq(min); });
if (stopping()) if (healthWait() == stopping)
return; return;
if (!app_.config().useTxTables()) if (!app_.config().useTxTables())
@@ -660,7 +660,7 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated)
[&db](LedgerIndex min) -> void { [&db](LedgerIndex min) -> void {
db->deleteTransactionsBeforeLedgerSeq(min); db->deleteTransactionsBeforeLedgerSeq(min);
}); });
if (stopping()) if (healthWait() == stopping)
return; return;
clearSql( clearSql(
@@ -672,12 +672,12 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated)
[&db](LedgerIndex min) -> void { [&db](LedgerIndex min) -> void {
db->deleteAccountTransactionsBeforeLedgerSeq(min); db->deleteAccountTransactionsBeforeLedgerSeq(min);
}); });
if (stopping()) if (healthWait() == stopping)
return; return;
} }
bool SHAMapStoreImp::HealthResult
SHAMapStoreImp::stopping() SHAMapStoreImp::healthWait()
{ {
auto age = ledgerMaster_->getValidatedLedgerAge(); auto age = ledgerMaster_->getValidatedLedgerAge();
OperatingMode mode = netOPs_->getOperatingMode(); OperatingMode mode = netOPs_->getOperatingMode();
@@ -695,7 +695,7 @@ SHAMapStoreImp::stopping()
lock.lock(); lock.lock();
} }
return stop_; return stop_ ? stopping : keepGoing;
} }
void void

View File

@@ -104,9 +104,8 @@ private:
std::uint32_t deleteBatch_ = 100; std::uint32_t deleteBatch_ = 100;
std::chrono::milliseconds backOff_{100}; std::chrono::milliseconds backOff_{100};
std::chrono::seconds ageThreshold_{60}; std::chrono::seconds ageThreshold_{60};
/// If the node is out of sync during an /// If the node is out of sync during an online_delete healthWait()
/// online_delete health check, sleep the thread /// call, sleep the thread for this time, and continue checking until
/// for this time, and continue checking until
/// recovery. /// recovery.
/// See also: "recovery_wait_seconds" in rippled-example.cfg /// See also: "recovery_wait_seconds" in rippled-example.cfg
std::chrono::seconds recoveryWaitTime_{5}; std::chrono::seconds recoveryWaitTime_{5};
@@ -199,7 +198,7 @@ private:
{ {
dbRotating_->fetchNodeObject( dbRotating_->fetchNodeObject(
key, 0, NodeStore::FetchType::synchronous, true); key, 0, NodeStore::FetchType::synchronous, true);
if (!(++check % checkHealthInterval_) && stopping()) if (!(++check % checkHealthInterval_) && healthWait() == stopping)
return true; return true;
} }
@@ -225,13 +224,14 @@ private:
/** /**
* This is a health check for online deletion that waits until rippled is * This is a health check for online deletion that waits until rippled is
* stable until returning. If the server is stopping, then it returns * stable before returning. It returns an indication of whether the server
* "true" to inform the caller to allow the server to stop. * is stopping.
* *
* @return Whether the server is stopping. * @return Whether the server is stopping.
*/ */
bool enum HealthResult { stopping, keepGoing };
stopping(); [[nodiscard]] HealthResult
healthWait();
public: public:
void void