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

[Cleanup] Avoid leaking deferred calls #931

Merged
merged 5 commits into from
Mar 21, 2022
Merged

[Cleanup] Avoid leaking deferred calls #931

merged 5 commits into from
Mar 21, 2022

Conversation

AnomalRoil
Copy link
Member

We had deferred calls that were issued in a for loop, and as such were "leaking".

This PR wraps the deferred calls and code into anonymous function, which means that the deferred calls are run at the end of each iteration instead of leaking until the end of the function execution.

Copy link
Member

@willscott willscott left a comment

Choose a reason for hiding this comment

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

looks good

}
// Using an anonymous function to not leak the defer
er = func() error {
store, err := boltdb.NewBoltStore(path.Join(storePath, core.DefaultDBFolder), conf.BoltOptions())
Copy link
Member

Choose a reason for hiding this comment

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

is it safe to make multiple bolt stores here? i'd prefer just one store so we don't potentially have multiple things attempting to open the same on-disk storage

Copy link
Member Author

Choose a reason for hiding this comment

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

My understanding is that these are all accessing different DBs: one for each "beaconID", so it should be fine. (It's part of these new "multi-beacon/multi-frequency" features).

So as I understand it we are storing each "beacon DB" in its own store instead of mashing them all in the same DB.

@AnomalRoil
Copy link
Member Author

So, I'm now pretty happy with how it works both locally and on the CI, so I consider merging it even if codecov complains we've reduced our coverage since we don't hit a error case anymore during the tests...
Fine for you @nikkolasg @willscott ?

Copy link
Member

@willscott willscott left a comment

Choose a reason for hiding this comment

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

Looks generally good to me

client/http/http.go Outdated Show resolved Hide resolved
core/drand_test.go Show resolved Hide resolved
core/util_test.go Show resolved Hide resolved
Copy link
Collaborator

@nikkolasg nikkolasg left a comment

Choose a reason for hiding this comment

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

LGTM !

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.

None yet

3 participants