Skip to content

Commit

Permalink
Merge pull request #2287 from marta-lokhova/use_HAS_hashes_for_publish
Browse files Browse the repository at this point in the history
Use all bucket hashes from HAS instead of relying on StateSnapshot fo…

Reviewed-by: MonsieurNicolas
  • Loading branch information
latobarita committed Sep 24, 2019
2 parents d38cc3a + 78ae9a6 commit ce3c064
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/history/HistoryManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ HistoryManagerImpl::takeSnapshotAndPublish(HistoryArchiveState const& has)
{
return;
}
// Ensure no merges are in-progress, and capture the bucket list hashes
// *before* doing the actual publish. This ensures that the HAS is in
// pristine state as returned by the database.
for (auto const& bucket : has.currentBuckets)
{
assert(!bucket.next.isLive());
}
auto allBucketsFromHAS = has.allBuckets();
auto ledgerSeq = has.currentLedger;
CLOG(DEBUG, "History") << "Activating publish for ledger " << ledgerSeq;
auto snap = std::make_shared<StateSnapshot>(mApp, has);
Expand All @@ -290,7 +298,11 @@ HistoryManagerImpl::takeSnapshotAndPublish(HistoryArchiveState const& has)

std::vector<std::shared_ptr<BasicWork>> seq{resolveFutures, writeSnap,
putSnap};
mPublishWork = mApp.getWorkScheduler().scheduleWork<PublishWork>(snap, seq);
// Pass in all bucket hashes from HAS. We cannot rely on StateSnapshot
// buckets here, because its buckets might have some futures resolved by
// now, differing from the state of the bucketlist during queueing.
mPublishWork = mApp.getWorkScheduler().scheduleWork<PublishWork>(
snap, seq, allBucketsFromHAS);
}

size_t
Expand Down
5 changes: 3 additions & 2 deletions src/historywork/PublishWork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ namespace stellar

PublishWork::PublishWork(Application& app,
std::shared_ptr<StateSnapshot> snapshot,
std::vector<std::shared_ptr<BasicWork>> seq)
std::vector<std::shared_ptr<BasicWork>> seq,
std::vector<std::string> const& bucketHashes)
: WorkSequence(
app,
fmt::format("publish-{:08x}", snapshot->mLocalState.currentLedger),
seq, BasicWork::RETRY_NEVER)
, mSnapshot(snapshot)
, mOriginalBuckets(mSnapshot->mLocalState.allBuckets())
, mOriginalBuckets(bucketHashes)
{
}

Expand Down
3 changes: 2 additions & 1 deletion src/historywork/PublishWork.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class PublishWork : public WorkSequence

public:
PublishWork(Application& app, std::shared_ptr<StateSnapshot> snapshot,
std::vector<std::shared_ptr<BasicWork>> seq);
std::vector<std::shared_ptr<BasicWork>> seq,
std::vector<std::string> const& bucketHashes);
~PublishWork() = default;

protected:
Expand Down

0 comments on commit ce3c064

Please sign in to comment.