91
91
BucketManagerImpl::initialize ()
92
92
{
93
93
ZoneScoped;
94
- std::string d = mApp . getConfig () .BUCKET_DIR_PATH ;
94
+ std::string d = mConfig .BUCKET_DIR_PATH ;
95
95
96
96
if (!fs::exists (d))
97
97
{
@@ -122,17 +122,17 @@ BucketManagerImpl::initialize()
122
122
mLockedBucketDir = std::make_unique<std::string>(d);
123
123
mTmpDirManager = std::make_unique<TmpDirManager>(d + " /tmp" );
124
124
125
- if (mApp . getConfig () .MODE_ENABLES_BUCKETLIST )
125
+ if (mConfig .MODE_ENABLES_BUCKETLIST )
126
126
{
127
127
mBucketList = std::make_unique<BucketList>();
128
128
129
- if (mApp . getConfig () .isUsingBucketListDB ())
129
+ if (mConfig .isUsingBucketListDB ())
130
130
{
131
131
mSnapshotManager = std::make_unique<BucketSnapshotManager>(
132
132
mApp ,
133
133
std::make_unique<BucketListSnapshot>(*mBucketList ,
134
134
LedgerHeader ()),
135
- mApp . getConfig () .QUERY_SNAPSHOT_LEDGERS );
135
+ mConfig .QUERY_SNAPSHOT_LEDGERS );
136
136
}
137
137
}
138
138
@@ -141,11 +141,10 @@ BucketManagerImpl::initialize()
141
141
// BUCKET_DIR_PATH, HISTORY_FILE_TYPE_SCP is persisted to the database
142
142
// so create the remaining ledger header, transactions and results
143
143
// directories
144
- createPublishDir (FileType::HISTORY_FILE_TYPE_LEDGER, mApp .getConfig ());
145
- createPublishDir (FileType::HISTORY_FILE_TYPE_TRANSACTIONS,
146
- mApp .getConfig ());
147
- createPublishDir (FileType::HISTORY_FILE_TYPE_RESULTS, mApp .getConfig ());
148
- HistoryManager::createPublishQueueDir (mApp .getConfig ());
144
+ createPublishDir (FileType::HISTORY_FILE_TYPE_LEDGER, mConfig );
145
+ createPublishDir (FileType::HISTORY_FILE_TYPE_TRANSACTIONS, mConfig );
146
+ createPublishDir (FileType::HISTORY_FILE_TYPE_RESULTS, mConfig );
147
+ HistoryManager::createPublishQueueDir (mConfig );
149
148
}
150
149
151
150
void
@@ -178,6 +177,7 @@ EvictionCounters::EvictionCounters(Application& app)
178
177
179
178
BucketManagerImpl::BucketManagerImpl (Application& app)
180
179
: mApp (app)
180
+ , mConfig (app.getConfig())
181
181
, mBucketList (nullptr )
182
182
, mSnapshotManager (nullptr )
183
183
, mTmpDirManager (nullptr )
299
299
BucketManagerImpl::deleteEntireBucketDir ()
300
300
{
301
301
ZoneScoped;
302
- std::string d = mApp . getConfig () .BUCKET_DIR_PATH ;
302
+ std::string d = mConfig .BUCKET_DIR_PATH ;
303
303
if (fs::exists (d))
304
304
{
305
305
// First clean out the contents of the tmpdir, as usual.
@@ -332,7 +332,7 @@ BucketManagerImpl::deleteTmpDirAndUnlockBucketDir()
332
332
// Then delete the lockfile $BUCKET_DIR_PATH/stellar-core.lock
333
333
if (mLockedBucketDir )
334
334
{
335
- std::string d = mApp . getConfig () .BUCKET_DIR_PATH ;
335
+ std::string d = mConfig .BUCKET_DIR_PATH ;
336
336
std::string lock = d + " /" + kLockFilename ;
337
337
releaseAssert (fs::exists (lock));
338
338
fs::unlockFile (lock);
@@ -343,14 +343,14 @@ BucketManagerImpl::deleteTmpDirAndUnlockBucketDir()
343
343
BucketList&
344
344
BucketManagerImpl::getBucketList ()
345
345
{
346
- releaseAssertOrThrow (mApp . getConfig () .MODE_ENABLES_BUCKETLIST );
346
+ releaseAssertOrThrow (mConfig .MODE_ENABLES_BUCKETLIST );
347
347
return *mBucketList ;
348
348
}
349
349
350
350
BucketSnapshotManager&
351
351
BucketManagerImpl::getBucketSnapshotManager () const
352
352
{
353
- releaseAssertOrThrow (mApp . getConfig () .isUsingBucketListDB ());
353
+ releaseAssertOrThrow (mConfig .isUsingBucketListDB ());
354
354
releaseAssert (mSnapshotManager );
355
355
return *mSnapshotManager ;
356
356
}
@@ -476,7 +476,7 @@ BucketManagerImpl::renameBucketDirFile(std::filesystem::path const& src,
476
476
std::filesystem::path const & dst)
477
477
{
478
478
ZoneScoped;
479
- if (mApp . getConfig () .DISABLE_XDR_FSYNC )
479
+ if (mConfig .DISABLE_XDR_FSYNC )
480
480
{
481
481
return rename (src.string ().c_str (), dst.string ().c_str ()) == 0 ;
482
482
}
@@ -492,7 +492,7 @@ BucketManagerImpl::adoptFileAsBucket(std::string const& filename,
492
492
std::unique_ptr<BucketIndex const > index)
493
493
{
494
494
ZoneScoped;
495
- releaseAssertOrThrow (mApp . getConfig () .MODE_ENABLES_BUCKETLIST );
495
+ releaseAssertOrThrow (mConfig .MODE_ENABLES_BUCKETLIST );
496
496
std::lock_guard<std::recursive_mutex> lock (mBucketMutex );
497
497
498
498
if (mergeKey)
@@ -566,7 +566,7 @@ BucketManagerImpl::adoptFileAsBucket(std::string const& filename,
566
566
void
567
567
BucketManagerImpl::noteEmptyMergeOutput (MergeKey const & mergeKey)
568
568
{
569
- releaseAssertOrThrow (mApp . getConfig () .MODE_ENABLES_BUCKETLIST );
569
+ releaseAssertOrThrow (mConfig .MODE_ENABLES_BUCKETLIST );
570
570
571
571
// We _do_ want to remove the mergeKey from mLiveFutures, both so that that
572
572
// map does not grow without bound and more importantly so that we drop the
@@ -681,7 +681,7 @@ BucketManagerImpl::putMergeFuture(
681
681
MergeKey const & key, std::shared_future<std::shared_ptr<Bucket>> wp)
682
682
{
683
683
ZoneScoped;
684
- releaseAssertOrThrow (mApp . getConfig () .MODE_ENABLES_BUCKETLIST );
684
+ releaseAssertOrThrow (mConfig .MODE_ENABLES_BUCKETLIST );
685
685
std::lock_guard<std::recursive_mutex> lock (mBucketMutex );
686
686
CLOG_TRACE (
687
687
Bucket,
@@ -704,7 +704,7 @@ BucketManagerImpl::getBucketListReferencedBuckets() const
704
704
{
705
705
ZoneScoped;
706
706
std::set<Hash> referenced;
707
- if (!mApp . getConfig () .MODE_ENABLES_BUCKETLIST )
707
+ if (!mConfig .MODE_ENABLES_BUCKETLIST )
708
708
{
709
709
return referenced;
710
710
}
@@ -743,7 +743,7 @@ BucketManagerImpl::getAllReferencedBuckets() const
743
743
{
744
744
ZoneScoped;
745
745
auto referenced = getBucketListReferencedBuckets ();
746
- if (!mApp . getConfig () .MODE_ENABLES_BUCKETLIST )
746
+ if (!mConfig .MODE_ENABLES_BUCKETLIST )
747
747
{
748
748
return referenced;
749
749
}
788
788
BucketManagerImpl::cleanupStaleFiles ()
789
789
{
790
790
ZoneScoped;
791
- if (mApp . getConfig () .DISABLE_BUCKET_GC )
791
+ if (mConfig .DISABLE_BUCKET_GC )
792
792
{
793
793
return ;
794
794
}
@@ -867,7 +867,7 @@ BucketManagerImpl::forgetUnreferencedBuckets()
867
867
CLOG_TRACE (Bucket,
868
868
" BucketManager::forgetUnreferencedBuckets dropping {}" ,
869
869
filename);
870
- if (!filename.empty () && !mApp . getConfig () .DISABLE_BUCKET_GC )
870
+ if (!filename.empty () && !mConfig .DISABLE_BUCKET_GC )
871
871
{
872
872
CLOG_TRACE (Bucket, " removing bucket file: {}" , filename);
873
873
std::filesystem::remove (filename);
@@ -974,7 +974,7 @@ BucketManagerImpl::snapshotLedger(LedgerHeader& currentHeader)
974
974
{
975
975
ZoneScoped;
976
976
Hash hash;
977
- if (mApp . getConfig () .MODE_ENABLES_BUCKETLIST )
977
+ if (mConfig .MODE_ENABLES_BUCKETLIST )
978
978
{
979
979
hash = mBucketList ->getHash ();
980
980
}
@@ -1005,25 +1005,29 @@ BucketManagerImpl::maybeSetIndex(std::shared_ptr<Bucket> b,
1005
1005
1006
1006
void
1007
1007
BucketManagerImpl::scanForEvictionLegacy (AbstractLedgerTxn& ltx,
1008
- uint32_t ledgerSeq)
1008
+ uint32_t ledgerSeq,
1009
+ SorobanNetworkConfig& networkConfig)
1009
1010
{
1010
1011
ZoneScoped;
1011
1012
releaseAssert (protocolVersionStartsFrom (ltx.getHeader ().ledgerVersion ,
1012
1013
SOROBAN_PROTOCOL_VERSION));
1013
- mBucketList ->scanForEvictionLegacy (
1014
- mApp , ltx, ledgerSeq, mBucketListEvictionCounters , mEvictionStatistics );
1014
+ mBucketList ->scanForEvictionLegacy (mApp , ltx, ledgerSeq,
1015
+ mBucketListEvictionCounters ,
1016
+ mEvictionStatistics , networkConfig);
1015
1017
}
1016
1018
1017
1019
void
1018
- BucketManagerImpl::startBackgroundEvictionScan (uint32_t ledgerSeq)
1020
+ BucketManagerImpl::startBackgroundEvictionScan (uint32_t ledgerSeq,
1021
+ bool callFromLedgerClose)
1019
1022
{
1020
- releaseAssert (mApp .getConfig ().isUsingBucketListDB ());
1023
+ releaseAssert (!threadIsMain () || !mConfig .parallelLedgerClose ());
1024
+ releaseAssert (mConfig .isUsingBucketListDB ());
1021
1025
releaseAssert (mSnapshotManager );
1022
1026
releaseAssert (!mEvictionFuture .valid ());
1023
1027
releaseAssert (mEvictionStatistics );
1024
1028
1025
1029
auto searchableBL = mSnapshotManager ->copySearchableBucketListSnapshot ();
1026
- auto const & cfg = mApp .getLedgerManager ().getSorobanNetworkConfig ();
1030
+ auto cfg = mApp .getLedgerManager ().getSorobanNetworkConfig ();
1027
1031
auto const & sas = cfg.stateArchivalSettings ();
1028
1032
1029
1033
using task_t = std::packaged_task<EvictionResult ()>;
@@ -1045,28 +1049,25 @@ BucketManagerImpl::startBackgroundEvictionScan(uint32_t ledgerSeq)
1045
1049
void
1046
1050
BucketManagerImpl::resolveBackgroundEvictionScan (
1047
1051
AbstractLedgerTxn& ltx, uint32_t ledgerSeq,
1048
- LedgerKeySet const & modifiedKeys)
1052
+ LedgerKeySet const & modifiedKeys, SorobanNetworkConfig& networkConfig )
1049
1053
{
1050
1054
ZoneScoped;
1051
- releaseAssert (threadIsMain ());
1055
+ releaseAssert (! threadIsMain () || ! mConfig . parallelLedgerClose ());
1052
1056
releaseAssert (mEvictionStatistics );
1053
1057
1054
1058
if (!mEvictionFuture .valid ())
1055
1059
{
1056
- startBackgroundEvictionScan (ledgerSeq);
1060
+ startBackgroundEvictionScan (ledgerSeq, false );
1057
1061
}
1058
1062
1059
1063
auto evictionCandidates = mEvictionFuture .get ();
1060
1064
1061
- auto const & networkConfig =
1062
- mApp .getLedgerManager ().getSorobanNetworkConfig ();
1063
-
1064
1065
// If eviction related settings changed during the ledger, we have to
1065
1066
// restart the scan
1066
1067
if (!evictionCandidates.isValid (ledgerSeq,
1067
1068
networkConfig.stateArchivalSettings ()))
1068
1069
{
1069
- startBackgroundEvictionScan (ledgerSeq);
1070
+ startBackgroundEvictionScan (ledgerSeq, false );
1070
1071
evictionCandidates = mEvictionFuture .get ();
1071
1072
}
1072
1073
@@ -1176,7 +1177,7 @@ BucketManagerImpl::assumeState(HistoryArchiveState const& has,
1176
1177
uint32_t maxProtocolVersion, bool restartMerges)
1177
1178
{
1178
1179
ZoneScoped;
1179
- releaseAssertOrThrow (mApp . getConfig () .MODE_ENABLES_BUCKETLIST );
1180
+ releaseAssertOrThrow (mConfig .MODE_ENABLES_BUCKETLIST );
1180
1181
1181
1182
for (uint32_t i = 0 ; i < BucketList::kNumLevels ; ++i)
1182
1183
{
@@ -1203,7 +1204,7 @@ BucketManagerImpl::assumeState(HistoryArchiveState const& has,
1203
1204
1204
1205
// Buckets on the BucketList should always be indexed when
1205
1206
// BucketListDB enabled
1206
- if (mApp . getConfig () .isUsingBucketListDB ())
1207
+ if (mConfig .isUsingBucketListDB ())
1207
1208
{
1208
1209
releaseAssert (curr->isEmpty () || curr->isIndexed ());
1209
1210
releaseAssert (snap->isEmpty () || snap->isIndexed ());
@@ -1328,7 +1329,7 @@ BucketManagerImpl::mergeBuckets(HistoryArchiveState const& has)
1328
1329
BucketMetadata meta;
1329
1330
MergeCounters mc;
1330
1331
auto & ctx = mApp .getClock ().getIOContext ();
1331
- meta.ledgerVersion = mApp . getConfig () .LEDGER_PROTOCOL_VERSION ;
1332
+ meta.ledgerVersion = mConfig .LEDGER_PROTOCOL_VERSION ;
1332
1333
BucketOutputIterator out (getTmpDir (), /* keepDeadEntries=*/ false , meta, mc,
1333
1334
ctx, /* doFsync=*/ true );
1334
1335
for (auto const & pair : ledgerMap)
@@ -1539,13 +1540,13 @@ BucketManagerImpl::scheduleVerifyReferencedBucketsWork()
1539
1540
Config const &
1540
1541
BucketManagerImpl::getConfig () const
1541
1542
{
1542
- return mApp . getConfig () ;
1543
+ return mConfig ;
1543
1544
}
1544
1545
1545
1546
std::shared_ptr<SearchableBucketListSnapshot>
1546
1547
BucketManagerImpl::getSearchableBucketListSnapshot ()
1547
1548
{
1548
- releaseAssert (mApp . getConfig () .isUsingBucketListDB ());
1549
+ releaseAssert (mConfig .isUsingBucketListDB ());
1549
1550
// Any other threads must maintain their own snapshot
1550
1551
releaseAssert (threadIsMain ());
1551
1552
if (!mSearchableBucketListSnapshot )
@@ -1560,7 +1561,7 @@ BucketManagerImpl::getSearchableBucketListSnapshot()
1560
1561
void
1561
1562
BucketManagerImpl::reportBucketEntryCountMetrics ()
1562
1563
{
1563
- if (!mApp . getConfig () .isUsingBucketListDB ())
1564
+ if (!mConfig .isUsingBucketListDB ())
1564
1565
{
1565
1566
return ;
1566
1567
}
0 commit comments