From 1a8e57f83bbc720b22bba0d1460a164520c06ef0 Mon Sep 17 00:00:00 2001 From: Garand Tyson Date: Tue, 17 Dec 2024 13:35:16 -0800 Subject: [PATCH] Cleanup --- src/catchup/ApplyBucketsWork.cpp | 3 ++- src/database/Database.cpp | 36 -------------------------------- src/main/ApplicationImpl.cpp | 17 +++++++++------ src/main/Config.cpp | 5 +++-- src/main/PersistentState.h | 2 ++ 5 files changed, 18 insertions(+), 45 deletions(-) diff --git a/src/catchup/ApplyBucketsWork.cpp b/src/catchup/ApplyBucketsWork.cpp index 099f10d70d..8358384018 100644 --- a/src/catchup/ApplyBucketsWork.cpp +++ b/src/catchup/ApplyBucketsWork.cpp @@ -104,7 +104,8 @@ ApplyBucketsWork::doReset() // The current size of this set is 1.6 million during BucketApply // (as of 12/20/23). There's not a great way to estimate this, so // reserving with some extra wiggle room - mSeenKeys.reserve(2'000'000); + static const size_t estimatedOfferKeyCount = 2'000'000; + mSeenKeys.reserve(estimatedOfferKeyCount); auto addBucket = [this](std::shared_ptr const& bucket) { if (bucket->getSize() > 0) diff --git a/src/database/Database.cpp b/src/database/Database.cpp index f61c2b5c9a..73cccdb6f6 100644 --- a/src/database/Database.cpp +++ b/src/database/Database.cpp @@ -252,48 +252,12 @@ Database::upgradeToCurrentSchema() putSchemaVersion(vers); } - // Tx meta column no longer supported - dropTxMetaIfExists(); maybeUpgradeToBucketListDB(); CLOG_INFO(Database, "DB schema is in current version"); releaseAssert(vers == SCHEMA_VERSION); } -void -Database::dropTxMetaIfExists() -{ - int txMetaExists{}; - std::string selectStr; - if (isSqlite()) - { - selectStr = "SELECT EXISTS (" - "SELECT 1 " - "FROM pragma_table_info('txhistory') " - "WHERE name = 'txmeta');"; - } - else - { - selectStr = "SELECT EXISTS (" - "SELECT 1 " - "FROM information_schema.columns " - "WHERE " - "table_name = 'txhistory' AND " - "column_name = 'txmeta');"; - } - - auto& st = getPreparedStatement(selectStr).statement(); - st.exchange(soci::into(txMetaExists)); - st.define_and_bind(); - st.execute(true); - - if (txMetaExists) - { - CLOG_INFO(Database, "Dropping txmeta column from txhistory table"); - getSession() << "ALTER TABLE txhistory DROP COLUMN txmeta;"; - } -} - void Database::maybeUpgradeToBucketListDB() { diff --git a/src/main/ApplicationImpl.cpp b/src/main/ApplicationImpl.cpp index e92dcf306f..8c9b2beafe 100644 --- a/src/main/ApplicationImpl.cpp +++ b/src/main/ApplicationImpl.cpp @@ -642,12 +642,18 @@ ApplicationImpl::validateAndLogConfig() } auto pageSizeExp = mConfig.BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT; + + // If the page size is less than 256 bytes, it is essentially + // indexing individual keys, so page size should be set to 0 + // instead. + static auto const pageSizeMinExponent = 8; + + // Any exponent above 31 will cause overflow + static auto const pageSizeMaxExponent = 31; + if (pageSizeExp != 0) { - // If the page size is less than 256 bytes, it is essentially - // indexing individual keys, so page size should be set to 0 - // instead. - if (pageSizeExp < 8) + if (pageSizeExp < pageSizeMinExponent) { throw std::invalid_argument( "BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT " @@ -655,8 +661,7 @@ ApplicationImpl::validateAndLogConfig() "indexing"); } - // Check if pageSize will cause overflow - if (pageSizeExp > 31) + if (pageSizeExp > pageSizeMaxExponent) { throw std::invalid_argument( "BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT " diff --git a/src/main/Config.cpp b/src/main/Config.cpp index da8fb98551..319fac7ce8 100644 --- a/src/main/Config.cpp +++ b/src/main/Config.cpp @@ -1065,6 +1065,7 @@ Config::processConfig(std::shared_ptr t) {"BACKGROUND_OVERLAY_PROCESSING", [&]() { BACKGROUND_OVERLAY_PROCESSING = readBool(item); }}, // TODO: Flags are no longer supported, remove in next release. + // https://github.com/stellar/stellar-core/issues/4581 {"BACKGROUND_EVICTION_SCAN", [&]() { CLOG_WARNING( @@ -1087,8 +1088,8 @@ Config::processConfig(std::shared_ptr t) "DEPRECATED_SQL_LEDGER_STATE is deprecated and " "ignored. Please remove from config"); }}, - // Still support EXPERIMENTAL_BUCKETLIST_DB* flags for - // captive-core for 21.0 release, remove in 21.1 release + // TODO: Remove experimental BucketListDB flags in p23 + // https://github.com/stellar/stellar-core/issues/4581 {"EXPERIMENTAL_BUCKETLIST_DB", [&]() { CLOG_WARNING( diff --git a/src/main/PersistentState.h b/src/main/PersistentState.h index 7dc359ae2e..6b65cbd1ad 100644 --- a/src/main/PersistentState.h +++ b/src/main/PersistentState.h @@ -28,6 +28,8 @@ class PersistentState kRebuildLedger, kLastSCPDataXDR, kTxSet, + // TODO: Remove kDBBackend in v23 + // https://github.com/stellar/stellar-core/issues/4582 kDBBackend, kLastEntry, };