lit: make sure to always close stores on errored start-up#1026
lit: make sure to always close stores on errored start-up#1026guggero merged 1 commit intolightninglabs:masterfrom
stores on errored start-up#1026Conversation
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.
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.
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.
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.
stoppint -> stopping
Will fix on next push after more review
There was a problem hiding this comment.
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.
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.
Thanks for the explanation, looks good!
ViktorT-11
left a comment
There was a problem hiding this comment.
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