Skip to content

Commit 321d367

Browse files
committed
Fixes after rebase
1 parent a9f06c6 commit 321d367

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

src/bucket/BucketUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ EvictionResultCandidates::isValid(uint32_t currLedgerSeq,
147147
// affect evictions scans.
148148
if (protocolVersionIsBefore(
149149
initialLedgerVers,
150-
BucketBase::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION) &&
150+
LiveBucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION) &&
151151
protocolVersionStartsFrom(
152152
currLedgerVers,
153-
BucketBase::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
153+
LiveBucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
154154
{
155155
return false;
156156
}

src/history/test/HistoryTests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1252,10 +1252,10 @@ TEST_CASE("Catchup with protocol upgrade", "[catchup][history]")
12521252
{
12531253
if (protocolVersionEquals(
12541254
Config::CURRENT_LEDGER_PROTOCOL_VERSION,
1255-
BucketBase::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
1255+
LiveBucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
12561256
{
12571257
testUpgrade(
1258-
BucketBase::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION);
1258+
LiveBucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION);
12591259
}
12601260
}
12611261
}

src/historywork/DownloadBucketsWork.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "historywork/GetAndUnzipRemoteFileWork.h"
1212
#include "historywork/VerifyBucketWork.h"
1313
#include "work/WorkWithCallback.h"
14-
#include "xdr/Stellar-contract-config-setting.h"
1514
#include <Tracy.hpp>
1615
#include <fmt/format.h>
1716
#include <mutex>
@@ -75,7 +74,7 @@ DownloadBucketsWork::resetIter()
7574
}
7675

7776
template <typename BucketT>
78-
bool
77+
void
7978
DownloadBucketsWork::onSuccessCb(
8079
Application& app, FileTransferInfo const& ft, std::string const& hash,
8180
int currId, std::map<std::string, std::shared_ptr<BucketT>>& buckets,
@@ -99,7 +98,6 @@ DownloadBucketsWork::onSuccessCb(
9998
/*mergeKey=*/nullptr,
10099
/*index=*/std::move(indexIter->second));
101100
buckets[hash] = b;
102-
return true;
103101
}
104102

105103
std::shared_ptr<BasicWork>
@@ -159,11 +157,12 @@ DownloadBucketsWork::yieldMoreWork()
159157
auto self = weakSelf.lock();
160158
if (self)
161159
{
162-
return onSuccessCb<HotArchiveBucket>(
163-
app, ft, hash, currId, self->mHotBuckets,
164-
self->mHotIndexMap, self->mHotIndexMapMutex);
160+
onSuccessCb<HotArchiveBucket>(app, ft, hash, currId,
161+
self->mHotBuckets,
162+
self->mHotIndexMap,
163+
self->mHotIndexMapMutex);
165164
}
166-
return false;
165+
return true;
167166
};
168167

169168
mNextHotBucketIter++;
@@ -182,11 +181,12 @@ DownloadBucketsWork::yieldMoreWork()
182181
auto self = weakSelf.lock();
183182
if (self)
184183
{
185-
return onSuccessCb<LiveBucket>(
186-
app, ft, hash, currId, self->mLiveBuckets,
187-
self->mLiveIndexMap, self->mLiveIndexMapMutex);
184+
onSuccessCb<LiveBucket>(app, ft, hash, currId,
185+
self->mLiveBuckets,
186+
self->mLiveIndexMap,
187+
self->mLiveIndexMapMutex);
188188
}
189-
return false;
189+
return true;
190190
};
191191

192192
mNextLiveBucketIter++;
@@ -203,12 +203,12 @@ DownloadBucketsWork::yieldMoreWork()
203203
}
204204

205205
// Add explicit template instantiations
206-
template bool DownloadBucketsWork::onSuccessCb<LiveBucket>(
206+
template void DownloadBucketsWork::onSuccessCb<LiveBucket>(
207207
Application&, FileTransferInfo const&, std::string const&, int,
208208
std::map<std::string, std::shared_ptr<LiveBucket>>&,
209209
std::map<int, std::unique_ptr<LiveBucketIndex const>>&, std::mutex&);
210210

211-
template bool DownloadBucketsWork::onSuccessCb<HotArchiveBucket>(
211+
template void DownloadBucketsWork::onSuccessCb<HotArchiveBucket>(
212212
Application&, FileTransferInfo const&, std::string const&, int,
213213
std::map<std::string, std::shared_ptr<HotArchiveBucket>>&,
214214
std::map<int, std::unique_ptr<HotArchiveBucketIndex const>>&, std::mutex&);

src/historywork/DownloadBucketsWork.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class DownloadBucketsWork : public BatchWork
2727
TmpDir const& mDownloadDir;
2828
std::shared_ptr<HistoryArchive> mArchive;
2929

30-
// Store indexes of downloaded buckets
30+
// Store indexes of downloaded buckets. Child processes will actually create
31+
// the indexes, but DownloadBucketsWork needs to maintain actual ownership
32+
// of the pointers so that the success callback can pass them to the
33+
// BucketManager. Must be protected by a mutex to avoid race conditions.
3134
std::map<int, std::unique_ptr<LiveBucketIndex const>> mLiveIndexMap;
3235
std::map<int, std::unique_ptr<HotArchiveBucketIndex const>> mHotIndexMap;
3336

@@ -38,7 +41,7 @@ class DownloadBucketsWork : public BatchWork
3841
int mHotIndexId{0};
3942

4043
template <typename BucketT>
41-
static bool
44+
static void
4245
onSuccessCb(Application& app, FileTransferInfo const& ft,
4346
std::string const& hash, int currId,
4447
std::map<std::string, std::shared_ptr<BucketT>>& buckets,

0 commit comments

Comments
 (0)