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

View File

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