Don't delete from tx table if it's not in use

This commit is contained in:
Mark Travis
2021-02-17 16:49:58 -08:00
committed by manojsdoshi
parent 735b8b7d48
commit f284a19246
3 changed files with 23 additions and 6 deletions

View File

@@ -2344,8 +2344,14 @@ LedgerMaster::getFetchPackCacheSize() const
boost::optional<LedgerIndex>
LedgerMaster::minSqlSeq()
{
if (!app_.config().reporting())
{
boost::optional<LedgerIndex> seq;
auto db = app_.getLedgerDB().checkoutDb();
*db << "SELECT MIN(LedgerSeq) FROM Ledgers", soci::into(seq);
return seq;
}
#ifdef RIPPLED_REPORTING
if (app_.config().reporting())
{
auto seq = PgQuery(app_.getPgPool())("SELECT min_ledger()");
if (!seq)
@@ -2359,10 +2365,7 @@ LedgerMaster::minSqlSeq()
return seq.asInt();
}
#endif
boost::optional<LedgerIndex> seq;
auto db = app_.getLedgerDB().checkoutDb();
*db << "SELECT MIN(LedgerSeq) FROM Ledgers", soci::into(seq);
return seq;
return {};
}
} // namespace ripple

View File

@@ -343,7 +343,8 @@ SHAMapStoreImp::run()
ledgerMaster_ = &app_.getLedgerMaster();
fullBelowCache_ = &(*app_.getNodeFamily().getFullBelowCache(0));
treeNodeCache_ = &(*app_.getNodeFamily().getTreeNodeCache(0));
transactionDb_ = &app_.getTxnDB();
if (app_.config().useTxTables())
transactionDb_ = &app_.getTxnDB();
ledgerDb_ = &app_.getLedgerDB();
if (advisoryDelete_)
canDelete_ = state_db_.getCanDelete();
@@ -695,6 +696,9 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated)
if (health())
return;
if (!app_.config().useTxTables())
return;
clearSql(
*transactionDb_,
lastRotated,

View File

@@ -835,6 +835,16 @@ ReportingETL::ReportingETL(Application& app, Stoppable& parent)
// if present, get endpoint from config
if (app_.config().exists("reporting"))
{
#ifndef RIPPLED_REPORTING
Throw<std::runtime_error>(
"Config file specifies reporting, but software was not built with "
"-Dreporting=1. To use reporting, configure CMake with "
"-Dreporting=1");
#endif
if (!app_.config().useTxTables())
Throw<std::runtime_error>(
"Reporting requires tx tables. Set use_tx_tables=1 in config "
"file, under [ledger_tx_tables] section");
Section section = app_.config().section("reporting");
JLOG(journal_.debug()) << "Parsing config info";