-
Notifications
You must be signed in to change notification settings - Fork 109
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
Conversation
There was a problem hiding this 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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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... |
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
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.