Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use all bucket hashes from HAS instead of relying on StateSnapshot fo… #2287

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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