diff --git a/docs/stellar-core_example.cfg b/docs/stellar-core_example.cfg index edc0680f90..b0952d150d 100644 --- a/docs/stellar-core_example.cfg +++ b/docs/stellar-core_example.cfg @@ -238,13 +238,13 @@ CATCHUP_RECENT=1024 # This limits the number that will be active at a time. MAX_CONCURRENT_SUBPROCESSES=10 -# AUTOMATIC_MAINTENANCE_PERIOD (integer, seconds) default 3600 +# AUTOMATIC_MAINTENANCE_PERIOD (integer, seconds) default 14400 # Interval between automatic maintenance executions # Set to 0 to disable automatic maintenance -AUTOMATIC_MAINTENANCE_PERIOD=3600 +AUTOMATIC_MAINTENANCE_PERIOD=14400 # AUTOMATIC_MAINTENANCE_COUNT (integer) default 50000 -# Number of unneeded rows in each table that will be removed during one +# Number of unneeded ledgers in each table that will be removed during one # maintenance run. # Set to 0 to disable automatic maintenance AUTOMATIC_MAINTENANCE_COUNT=5000 diff --git a/src/database/DatabaseUtils.cpp b/src/database/DatabaseUtils.cpp index 445a892347..9bf9ca1fec 100644 --- a/src/database/DatabaseUtils.cpp +++ b/src/database/DatabaseUtils.cpp @@ -22,7 +22,10 @@ deleteOldEntriesHelper(soci::session& sess, uint32_t ledgerSeq, uint32_t count, st.execute(true); if (st.got_data() && gotMin == soci::i_ok) { - uint32 m = std::min(curMin + count, ledgerSeq); + uint64 m64 = + std::min(static_cast(curMin) + count, ledgerSeq); + // safe to cast down as it's at most ledgerSeq + uint64 m = static_cast(m64); sess << "DELETE FROM " << tableName << " WHERE " << ledgerSeqColumn << " <= " << m; } diff --git a/src/ledger/LedgerManagerImpl.cpp b/src/ledger/LedgerManagerImpl.cpp index aa5198d676..ed2c61236e 100644 --- a/src/ledger/LedgerManagerImpl.cpp +++ b/src/ledger/LedgerManagerImpl.cpp @@ -807,9 +807,13 @@ void LedgerManagerImpl::deleteOldEntries(Database& db, uint32_t ledgerSeq, uint32_t count) { + soci::transaction txscope(db.getSession()); + db.clearPreparedStatementCache(); LedgerHeaderFrame::deleteOldEntries(db, ledgerSeq, count); TransactionFrame::deleteOldEntries(db, ledgerSeq, count); HerderPersistence::deleteOldEntries(db, ledgerSeq, count); + db.clearPreparedStatementCache(); + txscope.commit(); } void diff --git a/src/main/Config.cpp b/src/main/Config.cpp index 9b490e55da..f9b96b4904 100644 --- a/src/main/Config.cpp +++ b/src/main/Config.cpp @@ -42,7 +42,7 @@ Config::Config() : NODE_SEED(SecretKey::random()) MANUAL_CLOSE = false; CATCHUP_COMPLETE = false; CATCHUP_RECENT = 0; - AUTOMATIC_MAINTENANCE_PERIOD = std::chrono::seconds{3600}; + AUTOMATIC_MAINTENANCE_PERIOD = std::chrono::seconds{14400}; AUTOMATIC_MAINTENANCE_COUNT = 50000; ARTIFICIALLY_GENERATE_LOAD_FOR_TESTING = false; ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING = false; diff --git a/src/main/Maintainer.cpp b/src/main/Maintainer.cpp index 5ffe241d09..d3c6a95374 100644 --- a/src/main/Maintainer.cpp +++ b/src/main/Maintainer.cpp @@ -17,9 +17,12 @@ Maintainer::Maintainer(Application& app) : mApp{app}, mTimer{mApp} void Maintainer::start() { - if (mApp.getConfig().AUTOMATIC_MAINTENANCE_PERIOD.count() > 0 && - mApp.getConfig().AUTOMATIC_MAINTENANCE_COUNT > 0) + auto& c = mApp.getConfig(); + if (c.AUTOMATIC_MAINTENANCE_PERIOD.count() > 0 && + c.AUTOMATIC_MAINTENANCE_COUNT > 0) + { scheduleMaintenance(); + } } void