Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTyson committed Dec 17, 2024
1 parent da4b3d5 commit 1a8e57f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 45 deletions.
3 changes: 2 additions & 1 deletion src/catchup/ApplyBucketsWork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LiveBucket> const& bucket) {
if (bucket->getSize() > 0)
Expand Down
36 changes: 0 additions & 36 deletions src/database/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
17 changes: 11 additions & 6 deletions src/main/ApplicationImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,21 +642,26 @@ 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 "
"must be at least 8 or set to 0 for individual entry "
"indexing");
}

// Check if pageSize will cause overflow
if (pageSizeExp > 31)
if (pageSizeExp > pageSizeMaxExponent)
{
throw std::invalid_argument(
"BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT "
Expand Down
5 changes: 3 additions & 2 deletions src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ Config::processConfig(std::shared_ptr<cpptoml::table> 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(
Expand All @@ -1087,8 +1088,8 @@ Config::processConfig(std::shared_ptr<cpptoml::table> 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(
Expand Down
2 changes: 2 additions & 0 deletions src/main/PersistentState.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class PersistentState
kRebuildLedger,
kLastSCPDataXDR,
kTxSet,
// TODO: Remove kDBBackend in v23
// https://github.com/stellar/stellar-core/issues/4582
kDBBackend,
kLastEntry,
};
Expand Down

0 comments on commit 1a8e57f

Please sign in to comment.