Skip to content

Commit bb037ed

Browse files
committed
Cleanup
1 parent f3cbd03 commit bb037ed

5 files changed

+17
-11
lines changed

src/bucket/BucketList.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BucketLevel::getNext()
6363
void
6464
BucketLevel::setNext(FutureBucket const& fb)
6565
{
66-
assertThreadIsMain();
66+
releaseAssert(threadIsMain());
6767
mNextCurr = fb;
6868
}
6969

@@ -82,7 +82,7 @@ BucketLevel::getSnap() const
8282
void
8383
BucketLevel::setCurr(std::shared_ptr<Bucket> b)
8484
{
85-
assertThreadIsMain();
85+
releaseAssert(threadIsMain());
8686
mNextCurr.clear();
8787
mCurr = b;
8888
}
@@ -117,7 +117,7 @@ BucketList::shouldMergeWithEmptyCurr(uint32_t ledger, uint32_t level)
117117
void
118118
BucketLevel::setSnap(std::shared_ptr<Bucket> b)
119119
{
120-
assertThreadIsMain();
120+
releaseAssert(threadIsMain());
121121
mSnap = b;
122122
}
123123

src/bucket/BucketListSnapshot.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace stellar
1616
BucketListSnapshot::BucketListSnapshot(BucketList const& bl, uint32_t ledgerSeq)
1717
: mLedgerSeq(ledgerSeq)
1818
{
19-
assertThreadIsMain();
19+
releaseAssert(threadIsMain());
2020

2121
for (uint32_t i = 0; i < BucketList::kNumLevels; ++i)
2222
{
@@ -158,7 +158,7 @@ SearchableBucketListSnapshot::loadPoolShareTrustLinesByAccountAndAsset(
158158
ZoneScoped;
159159

160160
// This query should only be called during TX apply
161-
assertThreadIsMain();
161+
releaseAssert(threadIsMain());
162162
mSnapshotManager.maybeUpdateSnapshot(mSnapshot);
163163

164164
LedgerKeySet trustlinesToLoad;
@@ -194,7 +194,7 @@ SearchableBucketListSnapshot::loadInflationWinners(size_t maxWinners,
194194

195195
// This is a legacy query, should only be called by main thread during
196196
// catchup
197-
assertThreadIsMain();
197+
releaseAssert(threadIsMain());
198198
auto timer = mSnapshotManager.recordBulkLoadMetrics("inflationWinners", 0)
199199
.TimeScope();
200200

src/bucket/BucketManagerImpl.h

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class BucketManagerImpl : public BucketManager
4343
std::unique_ptr<TmpDirManager> mTmpDirManager;
4444
std::unique_ptr<TmpDir> mWorkDir;
4545
std::map<Hash, std::shared_ptr<Bucket>> mSharedBuckets;
46+
47+
// Lock for managing raw Bucket files or the bucket directory. This lock is
48+
// only required for file access, but is not required for logical changes to
49+
// the BucketList (i.e. addBatch).
4650
mutable std::recursive_mutex mBucketMutex;
4751
std::unique_ptr<std::string> mLockedBucketDir;
4852
medida::Meter& mBucketObjectInsertBatch;

src/bucket/BucketSnapshotManager.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BucketSnapshotManager::BucketSnapshotManager(
2424
, mBloomLookups(
2525
mMetrics.NewMeter({"bucketlistDB", "bloom", "lookups"}, "bloom"))
2626
{
27-
assertThreadIsMain();
27+
releaseAssert(threadIsMain());
2828
}
2929

3030
std::unique_ptr<SearchableBucketListSnapshot>
@@ -41,7 +41,7 @@ BucketSnapshotManager::recordBulkLoadMetrics(std::string const& label,
4141
{
4242
// For now, only keep metrics for the main thread. We can decide on what
4343
// metrics make sense when more background services are added later.
44-
assertThreadIsMain();
44+
releaseAssert(threadIsMain());
4545

4646
if (numEntries != 0)
4747
{
@@ -63,7 +63,7 @@ BucketSnapshotManager::getPointLoadTimer(LedgerEntryType t) const
6363
{
6464
// For now, only keep metrics for the main thread. We can decide on what
6565
// metrics make sense when more background services are added later.
66-
assertThreadIsMain();
66+
releaseAssert(threadIsMain());
6767

6868
auto iter = mPointTimers.find(t);
6969
if (iter == mPointTimers.end())
@@ -84,6 +84,9 @@ BucketSnapshotManager::maybeUpdateSnapshot(
8484
if (!snapshot ||
8585
snapshot->getLedgerSeq() != mCurrentSnapshot->getLedgerSeq())
8686
{
87+
// Should only update with a newer snapshot
88+
releaseAssert(!snapshot || snapshot->getLedgerSeq() <
89+
mCurrentSnapshot->getLedgerSeq());
8790
snapshot = std::make_unique<BucketListSnapshot>(*mCurrentSnapshot);
8891
}
8992
}
@@ -93,7 +96,7 @@ BucketSnapshotManager::updateCurrentSnapshot(
9396
std::unique_ptr<BucketListSnapshot const>&& newSnapshot)
9497
{
9598
releaseAssert(newSnapshot);
96-
assertThreadIsMain();
99+
releaseAssert(threadIsMain());
97100
std::lock_guard<std::recursive_mutex> lock(mSnapshotMutex);
98101
releaseAssert(!mCurrentSnapshot || newSnapshot->getLedgerSeq() >=
99102
mCurrentSnapshot->getLedgerSeq());

src/ledger/LedgerTxn.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -2782,7 +2782,6 @@ LedgerTxnRoot::Impl::commitChild(EntryIterator iter,
27822782
// Clearing the cache does not throw
27832783
mBestOffers.clear();
27842784
mEntryCache.clear();
2785-
mSearchableBucketListSnapshot.reset();
27862785

27872786
// std::unique_ptr<...>::reset does not throw
27882787
mTransaction.reset();

0 commit comments

Comments
 (0)