-
Notifications
You must be signed in to change notification settings - Fork 109
lit: make sure to always close stores on errored start-up
#1026
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
Conversation
Ensure that if any store init in the `stores` struct creation fails, then any successful stores are still closed during shutdown.
| returnErr = err | ||
| if g.stores.firewall != nil { | ||
| if err := g.stores.firewall.Stop(); err != nil { | ||
| log.Errorf("Error stoppint firewall DB: %v", |
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.
stoppint -> stopping
Could we combine this with the firewall's close function?
stores.closeFns["firewall"] = func() error {
err := stores.firewall.Stop()
if err != nil {
return fmt.Errorf("error stopping firewall DB: %v", err)
}
return firewallDB.Close()
}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.
or do we actually need closeFns, since we have access to all stores and can call their Close/Stop methods when shutting down?
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.
Could we combine this with the firewall's close function?
The reason i did not do that is cause we Start it outside. So feels like the same layer should be responsible for calling Stop.
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.
stoppint -> stopping
Will fix on next push after more review
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.
or do we actually need closeFns, since we have access to all stores and can call their Close/Stop methods when shutting down?
we could - but then need to do nil check for each. just thought that this was cleaner
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.
also, remember that this is all temporary - we're just doing it like this while we have these 2 versions. We will later force the migration and only have one. At that point, we dont need the stores struct and can handle each store individually in the terminal struct again
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.
Thanks for the explanation, looks good!
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 great, thanks for fixing this 🙏!
Ensure that if any store init in the
storesstruct creation fails, then any successful stores are still closed during shutdown.This addresses this review comment