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

Loki: recover from panic opening boltdb files #2983

Merged
merged 1 commit into from
Nov 24, 2020
Merged

Conversation

slim-bean
Copy link
Collaborator

Improves #2970 but isn't really a fix, it's still not clear to me what causes this panic and why we have never seen it in any of the existing places we open DB files.

@@ -116,3 +119,13 @@ func CompressFile(src, dest string) error {

return compressedFile.Sync()
}

// SafeOpenBoltdbFile will recover from a panic opening a DB file, and return the panic message in the err return object.
func SafeOpenBoltdbFile(path string) (boltdb *bbolt.DB, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a flag to remove the underlying file? I'm worried that if we see a corrupted file we will no longer panic, but we'll continue to loop trying to open a broken file. In some cases, we can probably redownload it from storage instead.

edit: we could add this in a followup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i debated this as well, i even started adding some comments to add a little defense to this but even that wasn't straight forward.

As it is now all the code that calls this function had existing error handling for non-panic problems so I decided since we capture the panic and return it as an error it should also then get handled by any existing error handling logic which should already cover these cases.

Not totally in love with this myself, seems like we should try to centralize the behavior of what to do when having a problem with a boltdb file.

@slim-bean slim-bean merged commit 6d44267 into master Nov 24, 2020
@slim-bean slim-bean deleted the recover-boltdb branch November 24, 2020 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants