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

Reset shared_future in FutureBucket when it's ready #2303

Merged
merged 2 commits into from
Oct 10, 2019

Conversation

marta-lokhova
Copy link
Contributor

This should resolve #2298 -- some standard library implementations (libstdc++) store task lambdas in the shared state, which we used to keep alive for a while (specifically, until level spill which could take months for low level buckets). This change explicitly resets shared_future once it's done.

The second change is a minor update to catchup, to stop referencing buckets earlier (currently we drop bucket references at the very end of a potentially long CatchupWork)

@stellar stellar deleted a comment from cocoi241116 Oct 7, 2019
@@ -299,7 +315,7 @@ FutureBucket::startMerge(Application& app, uint32_t maxProtocolVersion,

assert(curr);
assert(snap);
assert(!mOutputBucket.valid());
assert(!mOutputBucketFuture.valid());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we also need assert(!mOutputBucket) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, fixed (plus one other small simplification). If the change looks ok, I can squash the commits.

@@ -59,7 +59,8 @@ class FutureBucket
std::shared_ptr<Bucket> mInputCurrBucket;
std::shared_ptr<Bucket> mInputSnapBucket;
std::vector<std::shared_ptr<Bucket>> mInputShadowBuckets;
std::shared_future<std::shared_ptr<Bucket>> mOutputBucket;
std::shared_ptr<Bucket> mOutputBucket;
std::shared_future<std::shared_ptr<Bucket>> mOutputBucketFuture;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no test update?

Copy link
Contributor Author

@marta-lokhova marta-lokhova Oct 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not test the internals of FutureBucket, only its public interface, which functionally did not change (also, i initially had a test that verified that use_count remains the same when FutureBucket is resolved, but turns out that use_count returns an approximate value in the presence of multiple threads. Happy to add it back though if you prefer)

Copy link
Contributor

@MonsieurNicolas MonsieurNicolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor change requested on top of rebase-squash and we'll get this merged

}

if (mOutputBucketHash.empty())
{
mOutputBucketHash = binToHex(bucket->getHash());
mOutputBucketHash = binToHex(mOutputBucket->getHash());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mOutputBucket is only set above, right?

So why not setting mOutputBucketHash in the same place?
Actually maybe resolve should just start with if (LIVE_OUTPUT) { return mOutputBucket; } right now the code is written in an almost idempotent way, which doesn't make much sense

@MonsieurNicolas
Copy link
Contributor

r+ d50d4a6

latobarita added a commit that referenced this pull request Oct 10, 2019
Reset shared_future in FutureBucket when it's ready

Reviewed-by: MonsieurNicolas
@latobarita latobarita merged commit d50d4a6 into stellar:master Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some buckets are leaked
3 participants